E
etienno
HI,
I am trying to do this requirement with log4J. I have already post here
a comment about the fact that it seems quite difficult to extends the
DailyRollingFileAppender, this issu is related to my problem described
here:
For a Web Site, I need to be able to create logfiles where the file
name of the log is only known at runtime, and the number of log depends
of the number of user-roles in the website.
[User-role].MyLog.[Server IP Address or host name].[Current Day].log
Knowing there is 3 user role in my web site, Log4J should create 3
logs, one for each role. Each role will log in a different file... In
the future there might be more role, so I dont want to link this
feature to a log4j properties file (I mean the creation of an
properties-based Appender). The number of logFile should be dynamically
determined.
The [Server IP Address] will also be known only dynamically when
starting the server. It is the same thing for the [Current Day]. At
minight there must be a rolling file. This can be done like in the
DailyRollingFileAppender, overriding the naming convention (a date is
appended at the end of the logfile name (including the .log) only when
rolling the log file).
I have a small idea how to do it in theory:
- Create an custom appender based on DailyRollingFileAppender and
- Create a new LogFactory to overide the creation of the
"Custom"DailyRollingFileAppender to take in parameter the User-Role,
the IP Address and the Date.
- There must be somewhere a HashMap of Appenders.. each with there own
file name...
But in practice, I would like to have some hint about how to start the
code, is there some code I could based my work... or should I scrap
this crazy idea and make a "simple" Perl script to parse a single log4J
file and create the 3 files according this single file the log content?
Thanks for helping me
Etienne
Paris
I am trying to do this requirement with log4J. I have already post here
a comment about the fact that it seems quite difficult to extends the
DailyRollingFileAppender, this issu is related to my problem described
here:
For a Web Site, I need to be able to create logfiles where the file
name of the log is only known at runtime, and the number of log depends
of the number of user-roles in the website.
[User-role].MyLog.[Server IP Address or host name].[Current Day].log
Knowing there is 3 user role in my web site, Log4J should create 3
logs, one for each role. Each role will log in a different file... In
the future there might be more role, so I dont want to link this
feature to a log4j properties file (I mean the creation of an
properties-based Appender). The number of logFile should be dynamically
determined.
The [Server IP Address] will also be known only dynamically when
starting the server. It is the same thing for the [Current Day]. At
minight there must be a rolling file. This can be done like in the
DailyRollingFileAppender, overriding the naming convention (a date is
appended at the end of the logfile name (including the .log) only when
rolling the log file).
I have a small idea how to do it in theory:
- Create an custom appender based on DailyRollingFileAppender and
- Create a new LogFactory to overide the creation of the
"Custom"DailyRollingFileAppender to take in parameter the User-Role,
the IP Address and the Date.
- There must be somewhere a HashMap of Appenders.. each with there own
file name...
But in practice, I would like to have some hint about how to start the
code, is there some code I could based my work... or should I scrap
this crazy idea and make a "simple" Perl script to parse a single log4J
file and create the 3 files according this single file the log content?
Thanks for helping me
Etienne
Paris