How to add timestamp to the logfilename with the apache log4j

Posted by swati on Server Fault See other posts from Server Fault or by swati
Published on 2010-04-08T00:42:55Z Indexed on 2012/06/30 9:17 UTC
Read the original article Hit count: 296

Filed under:

I am new to using apache logger . I have downloaded the log4j-xx and i have the following text configuration file

# Set root logger level to DEBUG and its only appender to mainFormat.
log4j.rootLogger = TRACE, mainFormat, FILE


# mainFormat is set to be a ConsoleAppender.
log4j.appender.mainFormat=org.apache.log4j.ConsoleAppender

# mainFormat uses PatternLayout.
log4j.appender.mainFormat.layout=org.apache.log4j.PatternLayout
log4j.appender.mainFormat.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

#File makes a file of the output.
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=log4j_HAPR001_OutputFile.log
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

i use the above config file to create the log file. Now i wanted to add the current time stamp to the log file. Is there any way to do this. If yes can some one please give me the instructions how to do. Thanks in advance.

Regards, Swati

© Server Fault or respective owner

Related posts about apache2