You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Mark Lawson <ma...@emconnect.com> on 2014/04/23 10:49:45 UTC

Logging in servlet example

Hi,
I'm using the servlet example from camel 2.12 with Tomcat 7. It works fine,
but I can't get logging to work. Neither <log message="something"> or <to
uri="log:something"/> turn up in catalina.out or the log file.
I assume it's something about log4j but it's proving hard to find.
Any ideas?



--
View this message in context: http://camel.465427.n5.nabble.com/Logging-in-servlet-example-tp5750476.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Logging in servlet example

Posted by Grzegorz Grzybek <gr...@gmail.com>.
Hello Mark

Camel uses SLF4J as logging framework and you can use any compatible
logging implementation (log4j, logback, ...).

For one stop shop solution for Tomcat check my project:
https://github.com/grgrzybek/tomcat-slf4j-logback
With correct ZIP archive available here:
https://sourceforge.net/projects/tc-slf4jlogback/files/ you can configure
Tomcat to use SLF4J+Logback and the instructions will help you configure
your Web application to use separate logging configuration.

regards
Grzegorz Grzybek


2014-04-23 10:49 GMT+02:00 Mark Lawson <ma...@emconnect.com>:

> Hi,
> I'm using the servlet example from camel 2.12 with Tomcat 7. It works fine,
> but I can't get logging to work. Neither <log message="something"> or <to
> uri="log:something"/> turn up in catalina.out or the log file.
> I assume it's something about log4j but it's proving hard to find.
> Any ideas?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Logging-in-servlet-example-tp5750476.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Logging in servlet example

Posted by Mark Lawson <ma...@emconnect.com>.
Got it to work by defining the logger as a Bean using
http://stackoverflow.com/a/13160573/2625368

<bean id="myLogger" class="org.apache.log4j.Logger"
factory-method="getLogger">
    <constructor-arg value="servlet-example"/>
</bean>

and in my route

<to uri="bean:myLogger?method=info" />





--
View this message in context: http://camel.465427.n5.nabble.com/Logging-in-servlet-example-tp5750476p5750483.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Logging in servlet example

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Apr 23, 2014 at 10:49 AM, Mark Lawson <ma...@emconnect.com> wrote:
> Hi,
> I'm using the servlet example from camel 2.12 with Tomcat 7. It works fine,
> but I can't get logging to work. Neither <log message="something"> or <to
> uri="log:something"/> turn up in catalina.out or the log file.
> I assume it's something about log4j but it's proving hard to find.
> Any ideas?
>

There is a log4j.properties in the WAR file you need to adjust for logging.

Or some way remove log4j and whatnot from the WAR and use tomcat
logging. Though that is a general WAR in Tomcat problem. How to use a
central log configuration file. You can likely search the web for
answers about that.

>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Logging-in-servlet-example-tp5750476.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/