I know XFire is using commons-logging and not log4j explicitly; I tried to
redirect the output to a regular log4j.appender ( for example
org.apache.log4j.RollingFileAppender ). I know that if one doesn't specify a
particular Log implementation, then Apache Commons Logging (JCL) uses Log4J
as being the JCL primary default. Anyway I tried to force to use Log4J
logging (specifying the org.apache.commons.logging.impl.Log4JLogger in
log4j.properties) but with no success. In JCL docs is written: "In most
cases, including commons-logging.jar and your preferred logging
implementation in the classpath should be all that is required to use JCL."
I tried to include log4j.jar under WEB-INF/lib/ to be available for my
project and for JCL use as default underlying Log implementation but by
doing so, I got this exception from jboss app server upon deployment:
> 12:25:27,392 ERROR [STDERR] log4j:ERROR A
> "org.jboss.logging.util.OnlyOnceErrorHandler" object is not assignable
> to a "org.apache.log4j.spi.ErrorHandler" variable.
> 12:25:27,392 ERROR [STDERR] log4j:ERROR The class
> "org.apache.log4j.spi.ErrorHandler" was loaded by
> 12:25:27,392 ERROR [STDERR] log4j:ERROR [WebappClassLoader
> delegate: false
> repositories:
> /WEB-INF/classes/
> ----------> Parent Classloader:
> [EMAIL PROTECTED]
> ] whereas object of type
> 12:25:27,393 ERROR [STDERR] log4j:ERROR
> "org.jboss.logging.util.OnlyOnceErrorHandler" was loaded by
> [EMAIL PROTECTED]
> 12:25:27,491 ERROR [STDERR] log4j:ERROR Could not create an Appender.
> Reported error follows.
> 12:25:27,491 ERROR [STDERR] java.lang.ClassCastException:
> org.jboss.logging.appender.DailyRollingFileAppender
>
By reading all available threads in different forums I realized that one can
not deploy a war which includes a log4j.jar to jboss app server (log4j.jar
has to be excluded from the war deployment; that's the only way I could fix
the previous error caused by the presence of log4j.jar in the deployed war);
in this case the log4j.jar already present in the server lib directory (more
precise jboss/server/all/lib/ ) should step in and act as the default log
implementation for JCL right? Problem is that the log4j.properties is not
loaded by this log4j.jar from server lib directory ( even if I put the
log4j.properties in the correct location 'jboss/server/all/
deploy/myproject.war/WEB-INF/classes/' to be available, in the end it is
ignored ).
How can one specify the log implementation jar to be available to JCL when
deploying on jboss ?
Introducing the handlers in the service definition inside 'services.xml'
helps a lot, meaning that it records in the regular jboss server.log file
all the output from the web services deployed or published to be consumed by
other clients, but for the rest of the client web services deployed to just
consume remote web services (acting as pure simple clients) it's another
story because a separate process is spawn, running in a different console,
different JVM and therefore is the need to redirect and persist the output
to a separate log file like I tried to do with my 'log4j.properties'...
I have also another question please: for pure simple client web services
(that just access and consume other remote web services, having a main etc)
the following is the correct packaging/deployment/run approach ? = pack as a
jar, deploy them on app server and run the clients from within that jar ?
When I say pack as a jar is because I don't know a way to run the
client-ws-with-main if all is packaged in a war file (like I do for my own
regular web services which are published to be consumed by others and are
deployed as war files, but then again they don't contain main methods). I
know the war (web archive) is in fact a jar file as well, but when running a
java class with a main () from a jar then the ".jar" extension is expected
(and not ".war") right ? : like so:
java -cp 'classpath' myprojectjar.jar MainClass1
'eventual_parameters'
Is there another better way to package, deploy and run client web services ?
Any suggestions ?
(BTW checked write permissions, path's, config files, all commons related
libraries are deployed correctly with the war file, ... and everything is
fine...)
Details (using JBoss, JAXB2 bindings, xfire 1.2.6):
- the log4j.properties:
> org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
> # Set root logger level to DEBUG and related appenders (stdout for Console
> output, or XFire for client-log-file output)
> log4j.rootLogger=DEBUG, stdout, XFire
> # stdout is set to be a ConsoleAppender.
> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
> # stdout uses PatternLayout.
> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
> log4j.appender.stdout.layout.ConversionPattern=MIT: %-4r [%t] %-5p %c %x
> - %m%n
> # XFire is set to be a RollingFileAppender
> log4j.appender.XFire=org.apache.log4j.RollingFileAppender
> log4j.appender.XFire.Append=true
> log4j.appender.XFire.file=/path/log/xfire/WebServices.log
> log4j.appender.XFire.maxFileSize=10MB
> log4j.appender.XFire.maxBackupIndex=20
> log4j.appender.XFire.layout=org.apache.log4j.PatternLayout
> log4j.appender.XFire.layout.ConversionPattern=MIT: %-4r [%p] [%d{yyyy-
> MM-dd HH:mm:ss.SSS}] [%t] %-5p [%c] %x - %m%n
> # COMMONS & XFIRE - set custom log levels per package
> log4j.category.org.codehaus.xfire = DEBUG
> log4j.category.org.apache.commons.httpclient = DEBUG
> log4j.category.httpclient.wire = DEBUG
>
- in the client web service class I introduced this:
> //enable XFire logging
> private final static Log log = LogFactory.getLog(MyClient.class);
> .................
> // create a default service endpoint
> package.SpecificService service = client.getServiceHttpPort();
>
> Client port_client = Client.getInstance(service);
> // Tell XFire to cache a DOM document for the various in/out/fault
> flows
> port_client.addInHandler(new DOMInHandler());
> port_client.addOutHandler(new DOMOutHandler());
> port_client.addFaultHandler(new DOMOutHandler());
>
> // Add a logging handler to each flow
> port_client.addInHandler(new LoggingHandler());
> port_client.addOutHandler(new LoggingHandler());
> port_client.addFaultHandler(new LoggingHandler());
>
- in the service definition inside 'services.xml' I included this:
>
>
>
>
>
>
>
>
>
>
>
>
>
--
View this message in context:
http://www.nabble.com/Logging-System-tf4194383.html#a11956418
Sent from the XFire - User mailing list archive at Nabble.com.