You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ranabroto Ghosh <ra...@globalcharge.com> on 2018/08/06 12:33:31 UTC
Problem writing camel logs with log4j in a spring-boot application
Hi
I have a Spring-boot application with Apache Camel. All I am trying to
achieve here writing all logs(java log and also camel route level logs
using camel 'log' EIP) in a log file using log4j.
*My POM: *
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
*LOG4J properties file: *
log4j.rootLogger=info, rollinglog, rollingerrorlog
log4j.logger.org.apache.camel=INFO
# File output configuration
log4j.appender.rollinglog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.rollinglog.File=C://logs/testgateway.log
log4j.appender.rollinglog.Threshold=INFO
# roll over the file at the end of each day and append the date to the end
of the file
log4j.appender.rollinglog.DatePattern='.'yyyy-MM-dd
# Configure the layout for the log file
log4j.appender.rollinglog.layout=org.apache.log4j.PatternLayout
log4j.appender.rollinglog.layout.ConversionPattern=(%d) %p %t %c - %m%n
# File output configuration
log4j.appender.rollingerrorlog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.rollingerrorlog.File=C://logs/ testgateway.log
log4j.appender.rollingerrorlog.Threshold=ERROR
# roll over the file at the end of each day and append the date to the end
of the file
log4j.appender.rollingerrorlog.DatePattern='.'yyyy-MM-dd
# Configure the layout for the log file
log4j.appender.rollingerrorlog.layout=org.apache.log4j.PatternLayout
log4j.appender.rollingerrorlog.layout.ConversionPattern=(%d) %p %t %c - %m%n
*My Camel route: *
<route id="test-route" autoStartup="true">
<from uri="restlet:/test"/>
<!-- Logs are getting printed correctly in expected log file from below
java method-->
<to uri="bean:sendMessage?method=test"/>
<!-- Logs are not getting printed in expected log file from below log EIP-->
<log message="HEADER: ${headers}"/>
</route>
So I am confused why camel log not getting printed from camel contexts
wjere java logs are working fine, could you please guide me what I am
missing here
--
Kind Regards
Rana
Re: Problem writing camel logs with log4j in a spring-boot application
Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Aug 6, 2018 at 3:40 PM, RavinderReddy k <ra...@gmail.com> wrote:
> Simple solution is use logback.xml file include in your spring boot
> application that's all.
>
Yeah SB uses logback as the logger impl by default.
> On Mon, Aug 6, 2018, 9:37 AM Claus Ibsen <cl...@gmail.com> wrote:
>
>> Hi
>>
>> Its probably more of a Spring Boot question how to configure its logging.
>> I suggest to study their documentation.
>>
>> Camel uses the slf4j-api and that ought to work fine with SB.
>>
>> On Mon, Aug 6, 2018 at 2:33 PM, Ranabroto Ghosh
>> <ra...@globalcharge.com> wrote:
>> > Hi
>> > I have a Spring-boot application with Apache Camel. All I am trying to
>> > achieve here writing all logs(java log and also camel route level logs
>> > using camel 'log' EIP) in a log file using log4j.
>> >
>> >
>> >
>> > *My POM: *
>> >
>> > <dependency>
>> > <groupId>org.springframework.boot</groupId>
>> > <artifactId>spring-boot-starter-web</artifactId>
>> > <exclusions>
>> > <exclusion>
>> > <groupId>org.springframework.boot</groupId>
>> > <artifactId>spring-boot-starter-logging</artifactId>
>> > </exclusion>
>> > </exclusions>
>> > </dependency>
>> >
>> > <dependency>
>> > <groupId>org.apache.camel</groupId>
>> > <artifactId>camel-spring-boot</artifactId>
>> > <version>${camel.version}</version>
>> > </dependency>
>> >
>> > <dependency>
>> > <groupId>commons-logging</groupId>
>> > <artifactId>commons-logging</artifactId>
>> > <version>1.2</version>
>> > </dependency>
>> > <dependency>
>> > <groupId>log4j</groupId>
>> > <artifactId>log4j</artifactId>
>> > <version>1.2.16</version>
>> > </dependency>
>> >
>> >
>> > *LOG4J properties file: *
>> > log4j.rootLogger=info, rollinglog, rollingerrorlog
>> >
>> > log4j.logger.org.apache.camel=INFO
>> >
>> > # File output configuration
>> > log4j.appender.rollinglog=org.apache.log4j.DailyRollingFileAppender
>> > log4j.appender.rollinglog.File=C://logs/testgateway.log
>> > log4j.appender.rollinglog.Threshold=INFO
>> >
>> > # roll over the file at the end of each day and append the date to the
>> end
>> > of the file
>> > log4j.appender.rollinglog.DatePattern='.'yyyy-MM-dd
>> >
>> > # Configure the layout for the log file
>> > log4j.appender.rollinglog.layout=org.apache.log4j.PatternLayout
>> > log4j.appender.rollinglog.layout.ConversionPattern=(%d) %p %t %c - %m%n
>> >
>> > # File output configuration
>> > log4j.appender.rollingerrorlog=org.apache.log4j.DailyRollingFileAppender
>> > log4j.appender.rollingerrorlog.File=C://logs/ testgateway.log
>> > log4j.appender.rollingerrorlog.Threshold=ERROR
>> >
>> > # roll over the file at the end of each day and append the date to the
>> end
>> > of the file
>> > log4j.appender.rollingerrorlog.DatePattern='.'yyyy-MM-dd
>> >
>> > # Configure the layout for the log file
>> > log4j.appender.rollingerrorlog.layout=org.apache.log4j.PatternLayout
>> > log4j.appender.rollingerrorlog.layout.ConversionPattern=(%d) %p %t %c -
>> %m%n
>> >
>> >
>> > *My Camel route: *
>> >
>> > <route id="test-route" autoStartup="true">
>> > <from uri="restlet:/test"/>
>> >
>> > <!-- Logs are getting printed correctly in expected log file from below
>> > java method-->
>> > <to uri="bean:sendMessage?method=test"/>
>> >
>> > <!-- Logs are not getting printed in expected log file from below log
>> EIP-->
>> >
>> > <log message="HEADER: ${headers}"/>
>> > </route>
>> >
>> > So I am confused why camel log not getting printed from camel contexts
>> > wjere java logs are working fine, could you please guide me what I am
>> > missing here
>> >
>> > --
>> > Kind Regards
>> > Rana
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> http://davsclaus.com @davsclaus
>> Camel in Action 2: https://www.manning.com/ibsen2
>>
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: Problem writing camel logs with log4j in a spring-boot application
Posted by RavinderReddy k <ra...@gmail.com>.
Simple solution is use logback.xml file include in your spring boot
application that's all.
On Mon, Aug 6, 2018, 9:37 AM Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> Its probably more of a Spring Boot question how to configure its logging.
> I suggest to study their documentation.
>
> Camel uses the slf4j-api and that ought to work fine with SB.
>
> On Mon, Aug 6, 2018 at 2:33 PM, Ranabroto Ghosh
> <ra...@globalcharge.com> wrote:
> > Hi
> > I have a Spring-boot application with Apache Camel. All I am trying to
> > achieve here writing all logs(java log and also camel route level logs
> > using camel 'log' EIP) in a log file using log4j.
> >
> >
> >
> > *My POM: *
> >
> > <dependency>
> > <groupId>org.springframework.boot</groupId>
> > <artifactId>spring-boot-starter-web</artifactId>
> > <exclusions>
> > <exclusion>
> > <groupId>org.springframework.boot</groupId>
> > <artifactId>spring-boot-starter-logging</artifactId>
> > </exclusion>
> > </exclusions>
> > </dependency>
> >
> > <dependency>
> > <groupId>org.apache.camel</groupId>
> > <artifactId>camel-spring-boot</artifactId>
> > <version>${camel.version}</version>
> > </dependency>
> >
> > <dependency>
> > <groupId>commons-logging</groupId>
> > <artifactId>commons-logging</artifactId>
> > <version>1.2</version>
> > </dependency>
> > <dependency>
> > <groupId>log4j</groupId>
> > <artifactId>log4j</artifactId>
> > <version>1.2.16</version>
> > </dependency>
> >
> >
> > *LOG4J properties file: *
> > log4j.rootLogger=info, rollinglog, rollingerrorlog
> >
> > log4j.logger.org.apache.camel=INFO
> >
> > # File output configuration
> > log4j.appender.rollinglog=org.apache.log4j.DailyRollingFileAppender
> > log4j.appender.rollinglog.File=C://logs/testgateway.log
> > log4j.appender.rollinglog.Threshold=INFO
> >
> > # roll over the file at the end of each day and append the date to the
> end
> > of the file
> > log4j.appender.rollinglog.DatePattern='.'yyyy-MM-dd
> >
> > # Configure the layout for the log file
> > log4j.appender.rollinglog.layout=org.apache.log4j.PatternLayout
> > log4j.appender.rollinglog.layout.ConversionPattern=(%d) %p %t %c - %m%n
> >
> > # File output configuration
> > log4j.appender.rollingerrorlog=org.apache.log4j.DailyRollingFileAppender
> > log4j.appender.rollingerrorlog.File=C://logs/ testgateway.log
> > log4j.appender.rollingerrorlog.Threshold=ERROR
> >
> > # roll over the file at the end of each day and append the date to the
> end
> > of the file
> > log4j.appender.rollingerrorlog.DatePattern='.'yyyy-MM-dd
> >
> > # Configure the layout for the log file
> > log4j.appender.rollingerrorlog.layout=org.apache.log4j.PatternLayout
> > log4j.appender.rollingerrorlog.layout.ConversionPattern=(%d) %p %t %c -
> %m%n
> >
> >
> > *My Camel route: *
> >
> > <route id="test-route" autoStartup="true">
> > <from uri="restlet:/test"/>
> >
> > <!-- Logs are getting printed correctly in expected log file from below
> > java method-->
> > <to uri="bean:sendMessage?method=test"/>
> >
> > <!-- Logs are not getting printed in expected log file from below log
> EIP-->
> >
> > <log message="HEADER: ${headers}"/>
> > </route>
> >
> > So I am confused why camel log not getting printed from camel contexts
> > wjere java logs are working fine, could you please guide me what I am
> > missing here
> >
> > --
> > Kind Regards
> > Rana
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>
Re: Problem writing camel logs with log4j in a spring-boot application
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Its probably more of a Spring Boot question how to configure its logging.
I suggest to study their documentation.
Camel uses the slf4j-api and that ought to work fine with SB.
On Mon, Aug 6, 2018 at 2:33 PM, Ranabroto Ghosh
<ra...@globalcharge.com> wrote:
> Hi
> I have a Spring-boot application with Apache Camel. All I am trying to
> achieve here writing all logs(java log and also camel route level logs
> using camel 'log' EIP) in a log file using log4j.
>
>
>
> *My POM: *
>
> <dependency>
> <groupId>org.springframework.boot</groupId>
> <artifactId>spring-boot-starter-web</artifactId>
> <exclusions>
> <exclusion>
> <groupId>org.springframework.boot</groupId>
> <artifactId>spring-boot-starter-logging</artifactId>
> </exclusion>
> </exclusions>
> </dependency>
>
> <dependency>
> <groupId>org.apache.camel</groupId>
> <artifactId>camel-spring-boot</artifactId>
> <version>${camel.version}</version>
> </dependency>
>
> <dependency>
> <groupId>commons-logging</groupId>
> <artifactId>commons-logging</artifactId>
> <version>1.2</version>
> </dependency>
> <dependency>
> <groupId>log4j</groupId>
> <artifactId>log4j</artifactId>
> <version>1.2.16</version>
> </dependency>
>
>
> *LOG4J properties file: *
> log4j.rootLogger=info, rollinglog, rollingerrorlog
>
> log4j.logger.org.apache.camel=INFO
>
> # File output configuration
> log4j.appender.rollinglog=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.rollinglog.File=C://logs/testgateway.log
> log4j.appender.rollinglog.Threshold=INFO
>
> # roll over the file at the end of each day and append the date to the end
> of the file
> log4j.appender.rollinglog.DatePattern='.'yyyy-MM-dd
>
> # Configure the layout for the log file
> log4j.appender.rollinglog.layout=org.apache.log4j.PatternLayout
> log4j.appender.rollinglog.layout.ConversionPattern=(%d) %p %t %c - %m%n
>
> # File output configuration
> log4j.appender.rollingerrorlog=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.rollingerrorlog.File=C://logs/ testgateway.log
> log4j.appender.rollingerrorlog.Threshold=ERROR
>
> # roll over the file at the end of each day and append the date to the end
> of the file
> log4j.appender.rollingerrorlog.DatePattern='.'yyyy-MM-dd
>
> # Configure the layout for the log file
> log4j.appender.rollingerrorlog.layout=org.apache.log4j.PatternLayout
> log4j.appender.rollingerrorlog.layout.ConversionPattern=(%d) %p %t %c - %m%n
>
>
> *My Camel route: *
>
> <route id="test-route" autoStartup="true">
> <from uri="restlet:/test"/>
>
> <!-- Logs are getting printed correctly in expected log file from below
> java method-->
> <to uri="bean:sendMessage?method=test"/>
>
> <!-- Logs are not getting printed in expected log file from below log EIP-->
>
> <log message="HEADER: ${headers}"/>
> </route>
>
> So I am confused why camel log not getting printed from camel contexts
> wjere java logs are working fine, could you please guide me what I am
> missing here
>
> --
> Kind Regards
> Rana
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2