Hello,
Log4j is a very usefull tool. Here are some features I would find convenient :
1) RollingFileAppender
It's quite convenient to use Log4j for writing 'special' log messages into a
'Excel-like' file with
the .xls extention .
The pattern layout can contain tab "\t" delimited values in order to build a
csv file, directly
accessible via the http server with the proper mime-type information (i.e.
asking the web
browser to open automatically Excel).
It works fine but it would be great if a title (the first line of each log
file) could persist along
the creation of each new log file (using RollingFileAppender for example)
Would'nt it be a usefull feature to implement a new parameter, for example
"title" of
the following form ?:
<appender name="STAT" class="org.apache.log4j.rolling.RollingFileAppender">
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="FileNamePattern"
value="/avishistory/logs/stat.%d{yyyy-MM}.xls"/>
</rollingPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%m%n" />
<param name="Title" value="aaaaa\tbbbbbbb\tcccccccc\tddddd\teeee\r" />
</layout>
This title would be writen to each new log file prior to write 'normal' log
messages ...and
opening this log file thru the web serveur will open an Excel sheet having
automatically
a title for each column.
Some months ago, Curt Arnold suggested me to use the 'header' property but it
is not
what I want because it adds an header in front of each line (and I want a
header in front
of each file instead)
Do you have an example of a log4j.xml using this feature ?
2) SMTPAppender
The 1.3alpha8 version warns me with the following messages :
-The SMPTAppender.setEvaluatorClass is deprecated.
-It has been replaced with the more powerful SMPTAppender.setEvaluator method
I want to receive one mail for each warn,error or fatal message (not use the
buffer capability)
Does it mean that it is not possible to use ?:
<appender name="EMAIL" class="org.apache.log4j.net.SMTPAppender">
...
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="WARN"/>
<param name="LevelMax" value="FATAL"/>
</filter>
<param name="EvaluatorClass" value="com.adpcl.avis.AllwaysTrigger" />
My AllwaysTrigger always returns 'true'.
Do you have an example of a log4j.xml using this feature for 1.3 version ?
3) Right troncature
I would like to populate the object of my email with the first 20 characters of
the
message (%m) - since they probably contain the most usefull information - but
the
documentation says that it is not possible to troncate from the right side.
Is there a workarround ?
Thanks by advance to take time to help me !
Regards
Patrick