You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by misterbayne <mi...@yahoo.com> on 2011/07/20 21:33:44 UTC

Using Camel with log4j.xml

I am brand new to Camel and I am just starting to get my feet wet with all
that it does.  The first thing I noticed once I got a route working, was
that the logging was not going to my log file.  In fact, it is not following
any of the appenders I have setup in my log4j.xml file.  I am using Spring
to start my application and I have a camelContext in my Spring
application-context.xml file.  The log4j file has a logger for Camel:

<logger name="org.apache.camel">
     <level value="INFO" />
</logger>

but the output from Camel remains as the default logging style:

5559 [Camel (camel-1) thread #0 - ..........]

I know this has to be trivial but I cannot get these log messages into the
log file or in the application specific format.  Any help with this is
GREATLY appreciated!

Also, I noticed in my sftp route, Camel displays the username and password
in the log messages.  I figured that once I successfully got log4j working,
I would set the level to be WARN and this would not be an issue but I have
been wondering if there was a way to disable or limit all of the logging
from SftpOperations and/or RemoteFileProducer.

Thanks in advance for any assistance.

     Jeff

--
View this message in context: http://camel.465427.n5.nabble.com/Using-Camel-with-log4j-xml-tp4617036p4617036.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Using Camel with log4j.xml

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jul 21, 2011 at 4:55 PM, misterbayne <mi...@yahoo.com> wrote:
> Ashwin -
> Thanks a lot for the info.  Using the jar that Claus suggested, I was able
> to get the logging to work correctly.
>
> As for hiding usernames and passwords, I am still having an issue.  I was
> able to use jasypt successfully, as I encrypted my password in my properties
> file and was still able to make the sftp connection.  However, the password
> is still displayed in plain text in my log file.  I am using Spring to
> inject my encrypted password into the RouteBuilder bean.  I also tried using
> the Camel property directly from my RouteBuilder class, {{password}}, but
> still no luck.  The password is still displayed in the log where ever the
> endpoint is displayed.
>

I think we have fixed a few omissions of the password obfuscation in
the components.
You may try the new Camel 2.7.3 and 2.8.0. The latter is currently in
vote and expected to be released soon.

There is a post on @dev mailing list where you can find more details
about Camel 2.8 if you want to give it a try before its officially
released.



> Thanks!
>
>    Jeff
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Using-Camel-with-log4j-xml-tp4617036p4619747.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Using Camel with log4j.xml

Posted by misterbayne <mi...@yahoo.com>.
Ashwin -
Thanks a lot for the info.  Using the jar that Claus suggested, I was able
to get the logging to work correctly.

As for hiding usernames and passwords, I am still having an issue.  I was
able to use jasypt successfully, as I encrypted my password in my properties
file and was still able to make the sftp connection.  However, the password
is still displayed in plain text in my log file.  I am using Spring to
inject my encrypted password into the RouteBuilder bean.  I also tried using
the Camel property directly from my RouteBuilder class, {{password}}, but
still no luck.  The password is still displayed in the log where ever the
endpoint is displayed.

Thanks!

    Jeff

--
View this message in context: http://camel.465427.n5.nabble.com/Using-Camel-with-log4j-xml-tp4617036p4619747.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Using Camel with log4j.xml

Posted by Ashwin Karpe <ak...@fusesource.com>.
Hi,

There is some information that is further needed in order to resolve this
issue.

How are you wiring your logger object to Camel? I am assuming of course you
have a handcrafted logger. If not, please check the following link

http://camel.apache.org/log.html http://camel.apache.org/log.html 

As for hiding usernames and passwords, please check out the following link

http://camel.apache.org/jasypt.html http://camel.apache.org/jasypt.html 

Using jasypt, you should encrypt both and then pass these strings through
camel routes. The logger will give them literal treatment and garble the
username and password. Camel internally will do the right thing and convert
the values before reading.

Hope this helps.

Cheers,

Ashwin...

-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com 

Blog: http://opensourceknowledge.blogspot.com 
---------------------------------------------------------
--
View this message in context: http://camel.465427.n5.nabble.com/Using-Camel-with-log4j-xml-tp4617036p4617528.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Using Camel with log4j.xml

Posted by misterbayne <mi...@yahoo.com>.
Claus -
Thank you very much for the quick reply!  That jar was the answer  I had
looked right past it when I was searching through the distribution.
We are using Camel 2.7.0, by the way.

Thanks again!

     Jeff

--
View this message in context: http://camel.465427.n5.nabble.com/Using-Camel-with-log4j-xml-tp4617036p4619708.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Using Camel with log4j.xml

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jul 20, 2011 at 9:33 PM, misterbayne <mi...@yahoo.com> wrote:
> I am brand new to Camel and I am just starting to get my feet wet with all
> that it does.  The first thing I noticed once I got a route working, was
> that the logging was not going to my log file.  In fact, it is not following
> any of the appenders I have setup in my log4j.xml file.  I am using Spring
> to start my application and I have a camelContext in my Spring
> application-context.xml file.  The log4j file has a logger for Camel:
>
> <logger name="org.apache.camel">
>     <level value="INFO" />
> </logger>
>
> but the output from Camel remains as the default logging style:
>
> 5559 [Camel (camel-1) thread #0 - ..........]
>
> I know this has to be trivial but I cannot get these log messages into the
> log file or in the application specific format.  Any help with this is
> GREATLY appreciated!
>

What version of Camel are you using? I assume one of the 2.7 releases.

To use log4j you need to include the following JAR
org.slf4j:slf4j-log4j12:jar:1.6.1

It should be in the lib/optional directory of the distribution.

If you use maven you need to add the above as a dependency.


> Also, I noticed in my sftp route, Camel displays the username and password
> in the log messages.  I figured that once I successfully got log4j working,
> I would set the level to be WARN and this would not be an issue but I have
> been wondering if there was a way to disable or limit all of the logging
> from SftpOperations and/or RemoteFileProducer.
>
> Thanks in advance for any assistance.
>
>     Jeff
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Using-Camel-with-log4j-xml-tp4617036p4617036.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/