Advertisement

08.25.2007 at 03:38AM PDT, ID: 22786594
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

log4j - XML config logging for my package

Tags: log4j, xml
My package is com.mycompany.mypackage - i.e. classes are com.mycompany.MyClass etc. I'd like to log INFO from my package in a dedicated log file, using log4j. I need to use the XML configuration for reasons beyond the scope of this question.

I thought I could set it up thus:

--------8<--------
<?xml version="1.0" encoding= "UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

      <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
            <layout class="org.apache.log4j.PatternLayout">
                  <param name="ConversionPattern" value="%d %p [%c] - &lt;%m&gt;%n"/>
            </layout>
      </appender>

      <appender name="logfile" class="org.apache.log4j.RollingFileAppender">

            <param name="Threshold" value="DEBUG"/>
            <param name="Append" value="true"/>
            <param name="MaxFileSize" value="512KB"/>
            <param name="MaxBackupIndex" value="5"/>
            <param name="ImmediateFlush" value="true"/>

            <!-- file parameter is taken from the XML fragment, which is environment-specific -->
            <param name="File" value="mypackage.log"/>

            <layout class="org.apache.log4j.PatternLayout">
                  <param name="ConversionPattern" value="%d %p [%c] - %m%n"/>
            </layout>
      </appender>

      <logger name="com.mycompany.mypackage">
            <level value="info"/>
            <appender-ref ref="logfile"/>
            <appender-ref ref="stdout"/>
      </logger>

      <root>
            <priority value="warn"/>
            <appender-ref ref="stdout"/>
      </root>

</log4j:configuration>
--------8<--------

However, I don't get enything going into my log file. It remains 0 bytes.

Here's how I initialise the logger in my class:
--------8<--------
package com.mycompany.mypackage;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

pubic class MyClass {

    static final Log log = LogFactory.getLog(MyClass.class);

    // ....
}
--------8<--------

What am I doing wrong?
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: rstaveley
Solution Provided By: jim_cakalic
Participating Experts: 2
Solution Grade: A
Views: 168
Translate:
Loading Advertisement...
08.25.2007 at 08:08AM PDT, ID: 19768125

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.27.2007 at 10:00AM PDT, ID: 19776731

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.28.2007 at 12:46AM PDT, ID: 19781024

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.28.2007 at 05:42AM PDT, ID: 19782329

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.28.2007 at 05:55AM PDT, ID: 19782424

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.28.2007 at 06:03AM PDT, ID: 19782498

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.28.2007 at 06:19AM PDT, ID: 19782660

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.28.2007 at 07:02AM PDT, ID: 19783069

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.29.2007 at 02:23AM PDT, ID: 19789712

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.29.2007 at 06:35AM PDT, ID: 19791032

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.29.2007 at 10:24AM PDT, ID: 19793371

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.29.2007 at 10:32AM PDT, ID: 19793422

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.29.2007 at 12:07PM PDT, ID: 19794327

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.29.2007 at 12:15PM PDT, ID: 19794414

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.29.2007 at 12:45PM PDT, ID: 19794714

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.29.2007 at 02:57PM PDT, ID: 19795818

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.29.2007 at 11:08PM PDT, ID: 19797775

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.30.2007 at 05:02AM PDT, ID: 19799188

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.30.2007 at 05:06AM PDT, ID: 19799211

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.30.2007 at 05:08AM PDT, ID: 19799228

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.30.2007 at 05:12AM PDT, ID: 19799252

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.30.2007 at 05:33AM PDT, ID: 19799399

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.30.2007 at 05:39AM PDT, ID: 19799448

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.30.2007 at 05:42AM PDT, ID: 19799472

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.30.2007 at 05:56AM PDT, ID: 19799572

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.30.2007 at 05:58AM PDT, ID: 19799592

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
08.25.2007 at 08:08AM PDT, ID: 19768125
Use Logger.getLogger( MyClass), as explained here:

Each class in the Java application being logged can have an individual logger assigned to it or share a common logger with other classes. One can create any number of loggers for the application to suit specific logging needs. It is a common practice to create one logger for each class, with a name same as the fully-qualified class name. This practice helps organize log outputs in groups by the classes they originate from, and identify origin of log output, which is useful for debugging.

Log4j provides a default root logger that all user-defined loggers inherit from. Root logger is at the top of the logger hierarchy; in other words, root logger is either parent or ancestor of all logger objects created. If an application class doesn't have a logger assigned to it, it can still be logged using the root logger.

    For example: A class MyClass in com.foo.sampleapp application package can have a logger named com.foo.sampleapp.MyClass instantiated in it by using the Logger.getLogger("com.foo.sampleapp.MyClass") method. This logger will implicitly inherit from its nearest existing ancestor (maybe com.foo.sampleapp or com.foo or ...; or root logger if none exists), follow the same parent-child relationship as the class-subclass they log and have same package hierarchy as these classes.

http://www.developer.com/open/article.php/3097221
 
08.27.2007 at 10:00AM PDT, ID: 19776731

Rank: Wizard

On first blush, the configuration looks right. You might try adding -Dlog4j.debug=true to your startup and see if anything in the configuration debugging indicates a problem.

What's the environment for this? Is it a standalong Java application or are you running in an application server (Tomcat, JBoss, etc.)?

A silly question, but you are actually logging INFO level messages somewhere, right? Also, have you tried removing commons-logging from the mix and, for test purposes, use the log4j API directly?
 
08.28.2007 at 12:46AM PDT, ID: 19781024
This is running in a JBoss server, which had its own logging going to one server-wide logging file. To get my application to go into its own log, I took a cue from the only other application running on that server which is doing likewise and put its own log4j jar into WEB-INF/lib. The other application is using a log4j.properties file, though, which I wanted to avoid.

Yes, there are some log.info("xxx") messages in there. [Not a silly question, I've made sillier mistakes :-) ]

> -Dlog4j.debug=true

I can't get the SysAdmin to alter system properties, because they impact on all applications. I need to be a good citizen. But because that other application is getting its logging to work with log4j, I'm guessing that's set.

> have you tried removing commons-logging

Oh... it hadn't occurred to me to do that. I've been using commons-logging unthinkingly! I'll bet that's it.

I'll try the following and get back to you:
--------8<--------
package com.mycompany.mypackage;

import org.apache.log4j.Logger;

pubic class MyClass {

    private static org.apache.log4j.Logger log = Logger.getLogger(MyClass.class);

    // ....
}
--------8<--------
 
08.28.2007 at 05:42AM PDT, ID: 19782329
Sorry, I didn't respond to your comment, marklorenz. I didn't see the e-mail notification from EE and didn't spot it when I read jim_cakalic's post.

In any case I've tried your suggestion...

--------8<--------
package com.mycompany.mypackage;

import org.apache.log4j.Logger;

pubic class MyClass {

    private static org.apache.log4j.Logger log = Logger.getLogger(MyClass.class);

    // ....
}
--------8<--------

...but no cigar. I don't get my messages logged.

Somehow com.mycompany.mypackage.MyClass, doesn't seem to inherit from com.mycompany.mypackage.
 
08.28.2007 at 05:55AM PDT, ID: 19782424

Rank: Wizard

The log4j.debug system property is probably NOT set. That's something that you do only when you're having problems -- like this  ;-)

I know JBoss uses log4j for its own logging ... are you changing the server's conf/log4j.xml to add your configuration or are you using a separate log4j.xml file?

If separate file, where is it? I think it needs to be in WEB-INF/classes and log4j.jar in WEB-INF/lib. Make sure the classloader delegation policy is child-first or parent-last or some such so that the web app classloader will look to resolve class references before asking its parent.

If you're using the conf/log4j.xml, maybe having the log4j.jar in your WEB-INF/lib is causing a problem. Could be that the configuration is happening but your web app can't see it because a fresh unconfigured jar is being loaded by the web app classloader. If you /are/ using the conf/log4j.xml, try removing the log4j.jar from you war.
 
08.28.2007 at 06:03AM PDT, ID: 19782498
It is separate and in WEB-INF/classes. I am getting the 0 byte file being created, which means it must be getting seen to some extent.

> Make sure the classloader delegation policy is child-first or parent-last...

That's not easy to organise, because I don't have sysadmin access

 
08.28.2007 at 06:19AM PDT, ID: 19782660

Rank: Wizard

See http://docs.jboss.org/process-guide/en/html/logging.html, particularly sections 10.3.6 - 10.3.8.

In some of the browsing I've done on this topic, there are references to not being able to add a second console logger. Maybe you could try removing the console logger from your application-specific configuration and see if that makes any difference?
 
08.28.2007 at 07:02AM PDT, ID: 19783069
That's a great link, Jim. I'll have a go at setting up a RepositorySelector and get back.
 
08.29.2007 at 02:23AM PDT, ID: 19789712
I'm struggling implementing that RepositorySelector. Everything I do seems to prevent the .war from being able to deploy right now.

It's probably a consequence of something in the corporate development environment (clever plugins in Eclipse), I'm failing to understand. I'll get back to you, when I've got it to a useful point (or resolution!).
 
08.29.2007 at 06:35AM PDT, ID: 19791032

Rank: Wizard

OK. I haven't dealt much with RepositorySelectors. Just a question ... the 0-byte file that is being created ... is it definitely re-created each time you start your application? If you remove the file will it appear again when JBoss is restarted? I ask only because I want to make sure that your log4j.xml configuration is /really/ being read. If so, maybe we could get the debugging we want by adding a load-on-startup servlet that first sets the log4j.debug System property to true and then gets a Logger and logs messages at several different levels. That should bootstrap the local (web app) configuration process if it is happening. Then we can check to see if the file exists and if it has content. We should be able to see log4j output in the console log.
 
08.29.2007 at 10:24AM PDT, ID: 19793371
> Just a question ... the 0-byte file that is being created ... is it definitely re-created each time you start your application?

Good catch. It isn't. I couldn't unlink it, because of permissions (not being a sysadmin), but I didn't create a file with a new name.

I tried hacking a repository selector from http://docs.jboss.org/process-guide/en/html/logging.html 10.3.8, but it prevents my app from loading, when I put the following into web.xml:

      <servlet>
            <servlet-name>logSupportServlet</servlet-name>
            <servlet-class>com.mycompany.mypackage.MyRepositorySelector</servlet-class>
            <load-on-startup>6</load-on-startup>
      </servlet>

It seems to have problems casting my servlet in org.apache.catalina.core.StandardWrapper.loadServlet.

Here's the dump:

--------8<--------
war,id=846668036 WebModule) Servlet /com.mycompany.mypackage threw load() exception
java.lang.ClassCastException: com.mycompany.mypackage.MyRepositorySelector
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:925)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3857)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4118)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
        at sun.reflect.GeneratedMethodAccessor154.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
        at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:150)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
        at org.apache.catalina.core.StandardContext.init(StandardContext.java:5005)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
        at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:150)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
        at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeployInternal(TomcatDeployer.java:274)
        at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeploy(TomcatDeployer.java:91)
        at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:357)
        at org.jboss.web.WebModule.startModule(WebModule.java:68)
        at org.jboss.web.WebModule.startService(WebModule.java:46)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:897)
        at $Proxy0.start(Unknown Source)
        at org.jboss.system.ServiceController.start(ServiceController.java:418)
        at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
        at $Proxy28.start(Unknown Source)
        at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:394)
        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
        at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:121)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
        at $Proxy8.deploy(Unknown Source)
        at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:325)
        at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:483)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:215)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
--------8<--------
 
08.29.2007 at 10:32AM PDT, ID: 19793422
Do you reckon that means the servlet needs to extend org.apache.catalina.core.StandardWrapper?
 
08.29.2007 at 12:07PM PDT, ID: 19794327

Rank: Wizard

I was about to write the whole thing up for you but then I found this page:
http://thegioitinhoccuatoi.blogspot.com/feeds/posts/default

RepositorySelector isn't a servlet. You need a servlet that can instantiate the RepositorySelector and initialize the LogManager with it. The servlet needs to have a low load-on-startup value to ensure that it absolutely loads (and initializes) before any other servlet that might call Logger.getLogger. This is /very/ important. Any call to Logger.getLogger prior to setting the RepositorySelector will cause a default RepositorySelector to be installed which cannot be overridden.

When you navigate to the link above, search on the page for RepositorySelector. There is code for that (which I think is identical to what we'd already found) as well as a servlet implementation that does the necessary configuration. Give this a go.

Regards,
Jim
Accepted Solution
 
08.29.2007 at 12:15PM PDT, ID: 19794414
> Give this a go

I'm on the case. Many thanks, Jim.
 
08.29.2007 at 12:45PM PDT, ID: 19794714
This is looking better:

java.io.FileNotFoundException: /opt/jboss-4.0.2/bin/log4j.dtd

Just got to find that DTD and I should be in business.
 
08.29.2007 at 02:57PM PDT, ID: 19795818
Well I am generating that 0 byte file now, but that's as far as it goes.

I have a feeling that my problem is that Spring gets loaded before the Servlet does and I have Action classes getting loaded as singletons, which create instances of the logger, before the servlet that initialises the RepositorySelector is able to get in on the act.

<listener>            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

Spring loads POJOs, which I guess means that I need to get a ServletConfig to pass to the first bean to call MyRepositorySelector.init(config).

I've spotted http://www.blojsom.com/blog/david/java/2006/03/03/Getting-a-ServletConfig-reference-within-Spring.html