Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

logs of different package to be written to different logs  RSS feed

venkat bagavathi subramanian
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit;}\viewkind4\uc1\pard\f0\fs20 # Attach appender A1 to root. Set root level to Level.DEBUG.\par
log4j.rootLogger=DEBUG,A1, A2\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
# 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
log4j.appender.A1.layout.ConversionPattern=%p [%t] %c\{2\} (%M:%L) - %m%n\par
# Set the level of the logger named "org.apache.log4j.examples" to\par
# Level.INFO, attach appender A2.\par, A2\par
# Appender A2 writes to the file "test" in user's home.\par
# log4j.appender.A2=org.apache.log4j.RollingFileAppender\par
# log4j.appender.A2.File=d:/Integration/log/Test.log\par
# Truncate 'test' if it aleady exists.\par
# Appender A2 uses the PatternLayout.\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
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):,A3,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)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!