Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

logs of different package to be written to different logs

 
venkat bagavathi subramanian
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Basically i have 2 packages and i want the info logs from each of them to be written to a separate log file. Currently all info logs from both the packages go into a common log file(Integration.log). is it possible to specify that info logs from a package should go to one appender and those from the other package should go to another? if so how.
Below is the Log4j.prperties contents.
Pl help me how to achieve this.
regards
venkatB
-----------------------------------------------------------------------
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.15.1503;}\viewkind4\uc1\pard\f0\fs20 # Attach appender A1 to root. Set root level to Level.DEBUG.\par
log4j.rootLogger=DEBUG,A1, A2\par
\par
# A1 is set to be a FileAppender sending its output to\par
# System.out. However, only error messages and above will be printed\par
# in A1 because A1's threshold is set to Level.ERROR.\par
\par
# The fact that the root level is set to Prority.DEBUG only influences\par
# log requests made to the root logger. It has no influence on the\par
# *appenders* attached to root.\par
\par
log4j.appender.A1=org.apache.log4j.ConsoleAppender\par
log4j.appender.A1.Threshold=ERROR\par
\par
log4j.appender.A1.layout=org.apache.log4j.PatternLayout\par
log4j.appender.A1.layout.ConversionPattern=%p [%t] %c\{2\} (%M:%L) - %m%n\par
\par
# Set the level of the logger named "org.apache.log4j.examples" to\par
# Level.INFO, attach appender A2.\par
#log4j.logger.org.apache.log4j.examples=INFO, A2\par
\par
# Appender A2 writes to the file "test" in user's home.\par
log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender\par
# log4j.appender.A2=org.apache.log4j.RollingFileAppender\par
# log4j.appender.A2.File=d:/Integration/log/Test.log\par
log4j.appender.A2.File=/matsys01/t10001/DTI/Integration/logs/Integration.log\par
\par
# Truncate 'test' if it aleady exists.\par
log4j.appender.A2.Append=true\par
\par
# Appender A2 uses the PatternLayout.\par
log4j.appender.A2.layout=org.apache.log4j.PatternLayout\par
log4j.appender.A2.DatePattern='.'yyyy-MM-dd\par
log4j.appender.A2.layout.ConversionPattern=[%d\{ISO8601\}] %-5p %c\{2\}.%M: %m%n\par
}

[ May 12, 2006: Message edited by: venkat bagavathi subramanian ]
[ May 13, 2006: Message edited by: venkat bagavathi subramanian ]
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Define the level and appender for the packages' loggers (and define those appenders, not shown):

log4j.logger.com.foo=WARN,A3
log4j.logger.com.bar=DEBUG,A4

You may need to set the additivity flag if you don't want the messages in parent logs.
# Additivity set to false will not log the rootLogger (avoid dup messages
# when specifying the same ones)
log4j.additivity.com.foo=false
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic