You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Graf László <gr...@axis.hu> on 2005/02/04 13:12:40 UTC

More categories

Hi all,

In a project we want to use log4j.
With the base configuration it works fine, no matter of how many
appenders we define:

	log4j.rootCategory=error, D, S

	log4j.appender.D=org.apache.log4j.DailyRollingFileAppender
	log4j.appender.D.DatePattern='.'yyyy-MM-dd
	log4j.appender.D.File=base.#.log
	log4j.appender.D.layout=org.apache.log4j.PatternLayout
	log4j.appender.D.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

	log4j.appender.S=org.apache.log4j.net.SyslogAppender
	log4j.appender.S.SyslogHost=localhost
	log4j.appender.S.Facility=user
	log4j.appender.S.layout=org.apache.log4j.PatternLayout
	log4j.appender.S.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

But we would like to separate the logging process.
Ex:
1. all messages comming from JSP pages to go to a JSP category,
    wich contains a daily rolling appender and a syslog appender
    (with a JSP facility),
2. all messages comming from JSP tags to go to a JSP_TAG category,
    wich contains a daily rolling appender and a syslog appender
    (with a JSP_TAG facility),
3. all messages comming from JDBC classes to go to a JDBC category,
    wich contains a daily rolling appender and a syslog appender
    (with a JDBC facility)

So, we need three categories, as follows:

	log4j.rootCategory.JSP=error, D, S       # for messages comming from JSP pages
	log4j.rootCategory.JSP_TAGS=debug, D, S  # for messages comming from JSP tags
	log4j.rootCategory.JDBC=debug, D, S      # for messages comming from JDBC classes

	# ----------------------------------------
	log4j.appender.D=org.apache.log4j.DailyRollingFileAppender
	log4j.appender.D.DatePattern='.'yyyy-MM-dd
	log4j.appender.D.File=grafl.#.log
	log4j.appender.D.layout=org.apache.log4j.PatternLayout
	log4j.appender.D.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

	log4j.appender.R=org.apache.log4j.RollingFileAppender
	log4j.appender.R.File=/oracle/log4j_syslog/x.log
	log4j.appender.R.MaxFileSize=10MB
	log4j.appender.R.MaxBackupIndex=2
	log4j.appender.R.layout=org.apache.log4j.PatternLayout
	log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
	log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
etc.

How should we write the log4j.properties and use the appenders?

Thank you in advance,

-- 
László Graf


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org