logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kapil Anand <kapil...@yahoo.com>
Subject Need help with JULReceiver plugin
Date Thu, 13 Mar 2008 21:31:40 GMT

hi
I am trying to redirect some java.util.Logger events to a log4j managed log
file. log4j is not identifying the plugin element itself. I will appreciate
if you could point out where I am going wrong:

This is what I am doing:

1) Classpath:
--------------------------------
apache-log4j-component-1.0-20080219.044246-2.jar
Maven repository: http://people.apache.org/builds/logging/repo

apache-jul-log4j-bridge-1.0.0-20071030.022816-5.jar
Maven repository: http://people.apache.org/~psmith/logging.apache.org/repo

log4j-1.2.15
Maven repository: Default

2) log4j.xml
---------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="true">
        <appender name="DAILY_ROLL_FILE"
class="org.apache.log4j.DailyRollingFileAppender">
                <errorHandler
class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
                
                
                
                <layout class="org.apache.log4j.PatternLayout">
                        
                </layout>
        </appender>
        <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
                <errorHandler
class="org.jboss.logging.util.OnlyOnceErrorHandler" />
                
                
                <layout class="org.apache.log4j.PatternLayout">
                        
                </layout>
        </appender>

        <plugin name="julreceiver" class="org.apache.log4j.jul.JULReceiver"
/>

        <logger name="org.apache">
                <level value="INFO" />
        </logger>
        <logger name="org.jboss">
                <level value="INFO" />
        </logger>
        <logger name="org.springframework">
                <priority value="INFO" />
        </logger>
        <logger name="org.jgroups">
                <level value="WARN" />
        </logger>
        <logger name="com.mydomain">
                <level value="DEBUG" />
        </logger>
        <root>
                <priority value="DEBUG" />
                <appender-ref ref="DAILY_ROLL_FILE" />
               <!--  <appender-ref ref="CONSOLE" />  -->
        </root>
</log4j:configuration>

3) log4j debug
-----------------------
log4j:WARN Continuable parsing error 67 and column 11
log4j:WARN The content of element type "logger" must match
"(level?,appender-ref*)".
log4j: reset attribute= "false".
log4j: Threshold ="null".
log4j:WARN Unrecognized element plugin
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [org.apache] additivity to [true].
log4j: Level value for org.apache is  [INFO].
log4j: org.apache level set to INFO
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [org.jboss] additivity to [true].
log4j: Level value for org.jboss is  [INFO].
log4j: org.jboss level set to INFO
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [org.springframework] additivity to [true].
log4j: Level value for org.springframework is  [INFO].
log4j: org.springframework level set to INFO
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [org.jgroups] additivity to [true].
log4j: Level value for org.jgroups is  [WARN].
log4j: org.jgroups level set to WARN
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [com.mydomain] additivity to [true].
log4j: Level value for com.mydomain is  [DEBUG].
log4j: com.mydomain level set to DEBUG
log4j: Level value for root is  [DEBUG].
log4j: root level set to DEBUG
log4j: Class name: [org.apache.log4j.DailyRollingFileAppender]
log4j: Setting property [datePattern] to ['.'yyyy-MM-dd].
log4j: Setting property [file] to
[C:/opt/apps/msg-provider-1.0.0/logs/msg-provider.log].
log4j: Setting property [append] to [true].
log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
log4j: Setting property [conversionPattern] to [%d{ABSOLUTE} %-5p
[%c{2}]-%C.%M():%L - %m%n].
log4j: setFile called: c:/opt/apps/msg-provider-1.0.0/logs/msg-provider.log,
true
log4j: setFile ended
log4j: Appender [DAILY_ROLL_FILE] to be rolled at midnight.
log4j: Adding appender named [DAILY_ROLL_FILE] to category [root].

4) Source code to activate plugin enabled Repository (I don't know the
concepts here just picked up from another post). This is the code of my
application's main class:
----------------------------
public class RunProviderSpringApp
{
	private static final Object repositorySelectorGuard = new Object();
	private static final LoggerRepositoryExImpl repositoryExImpl = 
		new LoggerRepositoryExImpl(LogManager.getLoggerRepository());
  
	public static void main(String[] args)
	{
		// HACK FOR log4j plugins to work
		RepositorySelector repositorySelector = new RepositorySelector()
		{
			public LoggerRepository getLoggerRepository()
			{
		             return repositoryExImpl;    
			}			
		};		
		LogManager.setRepositorySelector(repositorySelector, 
										repositorySelectorGuard);
		RunSpringApp.main(args);
	}
}

thanks a lot for your time.
kapil
-- 
View this message in context: http://www.nabble.com/Need-help-with-JULReceiver-plugin-tp16039082p16039082.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


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


Mime
View raw message