logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tom Innes" <tin...@inforamp.net>
Subject RE: log4J / JBoss
Date Fri, 01 Feb 2002 19:29:30 GMT
Thanks everybody for their help.  We have managed to get it to work.  In
case anybody is interested here are the steps we went through in order to
get it to work with Jboss Version 2.4.3.

1. We extended Filter so we could filter out the userid
2. We created a jar and placed it in the lib/ext directory of Jboss.
3. We converted the properties file for Jboss Log4J Configuration to XML (
DOM Configurator Required for Filters ).  Which we are attaching.
4. We edited the Jboss.conf file located in conf/default directory.  Under
the Log4j service function / ARCHIVE section, we added the jar file to the
jars that are loaded with the log4j.jar thus putting it in the same
classloader.  We also changed the log4j.properties entry to use our new XML
file.

Please note that Version 2.4.3 of Jboss uses an out of date log4j.dtd file
and as a result you will get an error on Jboss startup indicating that it
cannot find the xmlns:log4j error.  The application runs fine.

Tom

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

        <!--
          Note the elements and attributes are order dependent
          Please read the log4j.dtd for the exact order
        -->

        <!--
          log4j.appender.Default=org.apache.log4j.FileAppender
          log4j.appender.Default.File=../log/server.log
          log4j.appender.Default.layout=org.apache.log4j.PatternLayout
          # Use the default JBoss format
          log4j.appender.Default.layout.ConversionPattern=[%c{1}] %m%n
          # Truncate if it aleady exists.
          log4j.appender.Default.Append=false
        -->


	<appender name="Default" class="org.apache.log4j.FileAppender">

            <param name="File" value="../log/server.log" />
            <param name="Append" value="false" />

            <layout class="org.apache.log4j.PatternLayout">
               <param name="ConversionPattern"
                      value="[%c{1}] %m%n"/>
            </layout>
	</appender>

        <!--
          log4j.appender.Console=org.jboss.logging.log4j.ConsoleAppender
          log4j.appender.Console.Threshold=INFO
          log4j.appender.Console.layout=org.apache.log4j.PatternLayout
          log4j.appender.Console.layout.ConversionPattern=[%c{1}] %m%n
        -->

	<appender name="Console" class="org.jboss.logging.log4j.ConsoleAppender">

            <param name="Threshold" value="info" />

            <layout class="org.apache.log4j.PatternLayout">
               <param name="ConversionPattern"
                      value="[%c{1}] %m%n"/>
            </layout>
	</appender>

        <appender name="EJBUserAppender"
class="org.apache.log4j.FileAppender">

            <param name="File" value="../log/FilteredUser.log" />
            <param name="Append" value="false" />
            <layout class="org.apache.log4j.PatternLayout">
               <param name="ConversionPattern"
                      value=" %p | %c{1} | [%m] | [ %x ] %n"/>
            </layout>
            <filter
class="com.ejbenterprise.util.logging.EJBEnterpriseUserFilter">
                <param name="filteredUser" value="Tom" />
            </filter>

	</appender>

        <appender name="EJBEnterpriseAppender"
class="org.apache.log4j.DailyRollingFileAppenderExt">

            <param name="DatePattern" value="'.'yyyy-MM-dd"/>
            <param name="MaxLogs" value="30"/>
            <param name="File" value="../log/EJBEnterprise.log" />
            <param name="Append" value="true" />
            <param name="Threshold" value="warn" />

            <layout class="org.apache.log4j.PatternLayout">
               <param name="ConversionPattern"
                      value="%d{yyMMdd HH:mm:ss}  | %p | %c | [%m] | [ %x ]
%n"/>
            </layout>
	</appender>

        <!--
          #Example of turning off logging for a category. Uncomment to turn
off.
          #log4j.category.DefaultDS=FATAL
        -->
        <!--
          <category name="DefaultDS">
            <priority value="fatal" />
          </category>
        -->


        <!--
          # Example of only showing INFO msgs for any categories under
org.jboss.util
          #log4j.category.org.jboss.util=INFO
        -->
        <!--
          <category name="org.jboss.util">
            <priority value="info" />
          </category>
        -->

        <!--
          # An example of enabling the custom TRACE level priority that is
used
          # by the JBoss internals to diagnose low level details. This
example
          # turns on TRACE level msgs for the org.jboss.ejb.plugins package
and its
          # subpackages. This will produce A LOT of logging output.

#log4j.category.org.jboss.ejb.plugins=TRACE#org.jboss.logging.log4j.TracePri
ority
        -->

<!-- These categories must be in most specific order first -->
<!-- Otherwise the least specific category will not be logged -->
<!-- This happens particularily for duplicates -->
<!-- Make Sure EJBEnterpriseAppender category is specified last -->

      	<category name="com.ejbenterprise.util">
	  <priority value="info" />
  	  <appender-ref ref="EJBUserAppender" />
	</category>

        <category name="com.ejbenterprise">
	  <priority value="debug" />
  	  <appender-ref ref="EJBEnterpriseAppender" />
	</category>





        <!-- log4j.rootCategory=DEBUG, Default, Console -->
	<root>
	   <priority value ="debug" />
   	   <appender-ref ref="Default" />
   	   <appender-ref ref="Console" />
	</root>


</log4j:configuration>
============================================================================
====================================


 -----Original Message-----
From: 	robert burrell donkin [mailto:robertdonkin@mac.com]
Sent:	January 31, 2002 1:54 PM
To:	Log4J Developers List
Subject:	Re: log4J / JBoss


On Wednesday, January 30, 2002, at 11:06 PM, Mark Womack wrote:

> Is it possible that your custom class and the log4j.jar are being accessed
> by different classloaders?

unless the log4j.jar is re-rolled with the addition of your extra class
and used to replace the one that jboss uses, it's almost certain that they
are in different classloaders. i'd say it's worth giving that re-roll a
try...

- robert

> I have seen similar problems with web
> applications in our servlet container when loading classes in the web
> application that are related to classes in the classpath of the container.
>
> just a thought,
> -Mark
>
> -----Original Message-----
> From: Tom Innes [mailto:tinnes@inforamp.net]
> Sent: Wednesday, January 30, 2002 3:05 PM
> To: 'Log4J Developers List'
> Subject: RE: log4J / JBoss
>
>
> I have tried your suggestions and extended the filter class instead of
> Category.  But Whenever JBoss starts we still get a NoClassDefFoundError
> (
> Which I have attached ). The custom filter is in a jar and has been placed
> in [JBOSS]/lib/ext. This error occurs when we set a classpath entry to
> this
> jar. If no classpath entry is set, we get a different
> ClassNotFoundException
> for the new filter class we created.
>
> Other posts on this topic lead me to believe it's a classloader problem
> with
> JBoss / log4j. Does anybody have some experience here they could share?
>
> We are using Jboss 2.4.3.
>
> Tom
>
> ================================
> java.lang.NoClassDefFoundError: org/apache/log4j/spi/Filter
> at java.lang.ClassLoader.defineClass0(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
> at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:290)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:120)
> at
> org.apache.log4j.helpers.OptionConverter.instantiateByClassName
> (OptionConver
> ter.java:301)
> at
>
org.apache.log4j.xml.DOMConfigurator.parseFilters(DOMConfigurator.java:246)
> at
>
org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:178)
> at
> org.apache.log4j.xml.DOMConfigurator.findAppenderByReference
> (DOMConfigurator
> .java:137)
> at
> org.apache.log4j.xml.DOMConfigurator.parseChildrenOfCategoryElement
> (DOMConfi
> gurator.java:354)
> at
>
org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:310)
> at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:684)
> at
> org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:586)
> at
> org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:520)
> at org.apache.log4j.xml.XMLWatchdog.doOnChange(DOMConfigurator.java:718)
> at
> org.apache.log4j.helpers.FileWatchdog.checkAndConfigure(FileWatchdog.java:
> 80
> )
> at org.apache.log4j.helpers.FileWatchdog.<init>(FileWatchdog.java:49)
> at org.apache.log4j.xml.XMLWatchdog.<init>(DOMConfigurator.java:710)
> at
>
org.apache.log4j.xml.DOMConfigurator.configureAndWatch(DOMConfigurator.java:
> 510)
> at org.jboss.logging.Log4jService.start(Log4jService.java:120)
> at org.jboss.logging.Log4jService.preRegister(Log4jService.java:189)
> at
> com.sun.management.jmx.MBeanServerImpl.preRegisterInvoker(MBeanServerImpl.
> ja
> va:2245)
> at
>
com.sun.management.jmx.MBeanServerImpl.createMBean(MBeanServerImpl.java:765)
> at javax.management.loading.MLet.getMBeansFromURL(MLet.java:540)
> at javax.management.loading.MLet.getMBeansFromURL(MLet.java:369)
> at org.jboss.Main.<init>(Main.java:193)
> at org.jboss.Main$1.run(Main.java:127)
> at java.security.AccessController.doPrivileged(Native Method)
> at org.jboss.Main.main(Main.java:123)
>
> ================================
>
>
>  -----Original Message-----
> From: 	Mark Womack [mailto:mwomack@bevocal.com]
> Sent:	January 29, 2002 7:06 PM
> To:	'Log4J Developers List'
> Subject:	RE: log4J / JBoss
>
> Tom,
>
> You might want to look at using the NDC or MDC classes to store your user
> code.  Then you could use a custom filter to print or not print a message
> based on the value of the NDC or MDC.
>
> -Mark
>
> -----Original Message-----
> From: Tom Innes [mailto:tinnes@inforamp.net]
> Sent: Tuesday, January 29, 2002 3:23 PM
> To: 'Log4J Developers List'
> Subject: RE: log4J / JBoss
>
>
> Hi Ceki,
>
> Maybe you can suggest a better alternative to what we are trying to
> accomplish.  We want to log the user code associated with a log message.
> Hence the reason we where trying to extend the category class.  Working
> in a
> multi-user environment we want all error messages to include the user
> code.
> In addition we want to be able to selectively turn on debug messages for
> a
> particular user by altering the properties file.  When we do so, we only
> want the debug messages for that user.
>
> Any suggestions would be appreciated.
>
> Tom
>
>  -----Original Message-----
> From: 	Ceki Gülcü [mailto:ceki@qos.ch]
> Sent:	January 29, 2002 5:52 PM
> To:	Log4J Developers List
> Subject:	Re: log4J / JBoss
>
>
> Tom,
>
> Do not extend the Category class and your problems will go away. Extending
> the
> category class is (almost) always a bad idea.
>
> Regards, Ceki
>
>
> At 17:11 29.01.2002 -0500, you wrote:
>> Hello,
>>
>> I'm not sure if this is the correct place to ask this question, but if
>> not,
>> I apologize.
>>
>> Can anyone assist me in getting log4j to work properly with JBoss 2.4.3?
>>  We
>> are extending the Category class with a our own. This works fine as a
>> standalone java program. We are having problems, however, getting it to
> work
>> with JBoss.
>>
>> The log4j.properties file looks like the following:
>>
>> ########################################################
>> # A log4j properties file suitable for replacing the
>> # default JBoss ConsoleLogging & FileLogging mbeans.
>>
>> # Set the JBossCategoryFactory as the default CategoryFactory
>>
log4j.categoryFactory=org.jboss.logging.log4j.JBossCategory$JBossCategoryFa
> c
>> tory
>>
>> log4j.rootCategory=DEBUG, Default, Console
>>
>> ### The server.log file appender
>> log4j.appender.Default=org.apache.log4j.FileAppender
>> log4j.appender.Default.File=../log/server.log
>> log4j.appender.Default.layout=org.apache.log4j.PatternLayout
>> # Use the default JBoss format
>> log4j.appender.Default.layout.ConversionPattern=[%c{1}] %m%n
>> # Truncate if it aleady exists.
>> log4j.appender.Default.Append=false
>> #Example of turning off logging for a category. Uncomment to turn off.
>> #log4j.category.DefaultDS=FATAL
>>
>> ### The console appender
>> log4j.appender.Console=org.jboss.logging.log4j.ConsoleAppender
>> log4j.appender.Console.Threshold=INFO
>> log4j.appender.Console.layout=org.apache.log4j.PatternLayout
>> log4j.appender.Console.layout.ConversionPattern=[%c{1}] %m%n
>>
>> # Example of only showing INFO msgs for any categories under
>> org.jboss.util
>> #log4j.category.org.jboss.util=INFO
>>
>> # An example of enabling the custom TRACE level priority that is used
>> # by the JBoss internals to diagnose low level details. This example
>> # turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
>> # subpackages. This will produce A LOT of logging output.
>>
#log4j.category.org.jboss.ejb.plugins=TRACE#org.jboss.logging.log4j.TracePr
> i
>> ority
>>
>>
>>
>> # EJBEnterprise Changes FOLLOW..........
>>
>> # A log4j properties file suitable for replacing the
>> # default JBoss ConsoleLogging & FileLogging mbeans.
>>
>> # Set the JBossCategoryFactory as the default CategoryFactory
>> #log4j.rootCategory=DEBUG
>>
>> # Following lines have been added for EJBUserCategory
>>
>> # set up the category factory
>>
log4j.categoryFactory=com.ejbenterprise.util.logging.EJBUserCategoryFactory
>> log4j.factory.ejbuser=Greg
>>
>> # set up the appender
>> log4j.appender.EJBUserAppender=org.apache.log4j.FileAppender
>> log4j.appender.EJBUserAppender.File=FilteredUser.log
>>
log4j.appender.EJBUserAppender.layout=com.ejbenterprise.util.logging.EJBUse
> r
>> PatternLayout
>> log4j.appender.EJBUserAppender.layout.ConversionPattern=User: %u [%c{1}]
>> %m%n
>> log4j.appender.EJBUserAppender.Append=false
>>
>>
>> # set up logging for a class
>> log4j.category.com.ejbenterprise.util.server=DEBUG, EJBUserAppender
>> ##################################################
>>
>>
>> Now, when the server starts, we are getting ClassNotFoundException for
>> core
>> log4j classes like Category, Priority etc. Does anybody know why this
>> happens and what the correct way to configure JBoss / log4j is?
>>
>> -Tom
>>
>>
>> --
>> To unsubscribe, e-mail:   <mailto:log4j-dev-
>> unsubscribe@jakarta.apache.org>
>> For additional commands, e-mail: <mailto:log4j-dev-
>> help@jakarta.apache.org>
>
> --
> Ceki Gülcü
>
>
>
> --
> To unsubscribe, e-mail:   <mailto:log4j-dev-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:log4j-dev-
> help@jakarta.apache.org>
>
>
>
>
>
> --
> To unsubscribe, e-mail:   <mailto:log4j-dev-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:log4j-dev-
> help@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:   <mailto:log4j-dev-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:log4j-dev-
> help@jakarta.apache.org>
>
>
>
>
>
> --
> To unsubscribe, e-mail:   <mailto:log4j-dev-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:log4j-dev-
> help@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:   <mailto:log4j-dev-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:log4j-dev-
> help@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:log4j-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-dev-help@jakarta.apache.org>





--
To unsubscribe, e-mail:   <mailto:log4j-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-dev-help@jakarta.apache.org>


Mime
View raw message