configure log4j file -


i have log4j.config

<appender name="fileinfostatistics" class="org.apache.log4j.rollingfileappender"> <param name="file" value="${log.dir}/t_statistics.log" /> <param name="maxfilesize" value="8000kb"/> <!-- keep 1 backup file --> <param name="maxbackupindex" value="1"/> <layout class="org.apache.log4j.patternlayout">   <param name="conversionpattern" value="%d %5p %c{1} - %m%n" /> </layout> <filter class="org.apache.log4j.varia.levelrangefilter">   <param name="levelmin" value="info" /> </filter> </appender> 

but when file t_statistics.log created firt time , 1 line e.g log file, possible log4j.config?

i saw possible en log4net with:

<param name="header" value="xxxx" 

is there in log4j?

well, after research found solution problem, said if useful.

i have created custom appender:

package com.mycompany.logger;  import org.apache.log4j.patternlayout;  public class mypatterlayout extends patternlayout  {       @override       public string getheader()     {           return "message id, file name, start time, end time, status" +  system.getproperty("line.separator");     } }   

and have configured log4j.xml:

<appender name="console" class="org.apache.log4j.consoleappender">  <param name="target" value="system.out"/>  <layout class="com.mycompany.logger.mypatterlayout">      <param name="conversionpattern" value="%-5p %c{1} - %m%n"/> </layout> 

and result:

message id, file name, start time, end time, status debug app - here debug info  app - here info warn  app - here warn  error app - here error fatal app - here fatal 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -