Take into account that the log level of your logging statements will affect
whether they are displayed on servicemix.log or not. The default
configuration sets the log level for the ROOT logger to INFO, meaning that
only statements with severity equal or above INFO will actually appear on
the log file (INFO, WARN, ERROR).

You can configure the logging level of the ROOT logger in the config file
that Jean-Baptiste mentioned, so you can decrease it to DEBUG or TRACE if
you want to see more verbosity.

I recommend that you use the SLF4j API from within your code, even though
PAX Logging will capture the output from various other frameworks as Gert
mentioned. To add the SLF4J dependency:

    <dependency>

      <groupId>org.slf4j</groupId>

      <artifactId>slf4j-api</artifactId>

      <version>...</version>

    </dependency>
Check what version of SLF4J your SMX container is using and copy it to the
version element for a quick start.

Regards,
Raúl.

On 24 January 2012 08:44, Jean-Baptiste Onofré <j...@nanthrax.net> wrote:

> Hi Gert,
>
> maybe I misunderstood the requirement. If the user want to create its own
> log file, he has to modify the org.ops4j.pax.logging.cfg file (to add its
> logger/appender).
>
> Else, if it's just to log into servicemix.log, as the rootLogger does it
> already, as you said, just logging (using slf4j, commons-logging, etc) is
> enough ;)
>
> Regards
> JB
>
>
> On 01/24/2012 09:38 AM, Gert Vanthienen wrote:
>
>> L.S.,
>>
>> You probably don't have edit this configuration file at all - if you want,
>> you can use it to e.g. create a separate log file for your own code or
>> something, but if you just want to write to servicemix.log, everything
>> should be good to go.
>>
>> Just use any of the logging frameworks you're familiar with (slf4j, log4j,
>> commons-logging, ...) from within your own Java code.  In ServiceMix,
>> logging from all these frameworks is being handled by Pax Logging, so it
>> will automatically end up in the servicemix.log file.
>>
>> Regards,
>>
>> Gert Vanthienen
>> ------------------------
>> FuseSource
>> Web: http://fusesource.com
>> Blog: 
>> http://gertvanthienen.**blogspot.com/<http://gertvanthienen.blogspot.com/>
>>
>>
>> On Mon, Jan 23, 2012 at 5:57 PM, Castyn<eric.ben...@gmail.com>  wrote:
>>
>>  Is there an example of this somewhere, I am fairly new to the majority of
>>> this.
>>>
>>> In the file you mentioned I see
>>>
>>> # Root logger
>>> log4j.rootLogger = INFO, out, osgi:VmLogAppender
>>> log4j.throwableRenderer=org.**apache.log4j.**OsgiThrowableRenderer
>>>
>>> # CONSOLE appender not used by default
>>> log4j.appender.stdout=org.**apache.log4j.ConsoleAppender
>>> log4j.appender.stdout.layout=**org.apache.log4j.PatternLayout
>>> log4j.appender.stdout.layout.**ConversionPattern=%d{ABSOLUTE} | %-5.5p |
>>> %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} -
>>> %X{bundle.version} | %m%n
>>>
>>> # File appender
>>> log4j.appender.out=org.apache.**log4j.RollingFileAppender
>>> log4j.appender.out.layout=org.**apache.log4j.PatternLayout
>>> log4j.appender.out.layout.**ConversionPattern=%d{ABSOLUTE} | %-5.5p |
>>> %-16.16t
>>> | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} |
>>> %m%n
>>> log4j.appender.out.file=${**karaf.data}/log/servicemix.log
>>> log4j.appender.out.append=true
>>> log4j.appender.out.**maxFileSize=100MB
>>> log4j.appender.out.**maxBackupIndex=10
>>>
>>> # Sift appender
>>> log4j.appender.sift=org.**apache.log4j.sift.**MDCSiftingAppender
>>> log4j.appender.sift.key=bundle**.name <http://bundle.name>
>>> log4j.appender.sift.default=**servicemix
>>> log4j.appender.sift.appender=**org.apache.log4j.FileAppender
>>> log4j.appender.sift.appender.**layout=org.apache.log4j.**PatternLayout
>>> log4j.appender.sift.appender.**layout.ConversionPattern=%d{**ABSOLUTE}
>>> | %-5.5p
>>> | %-16.16t | %-32.32c{1} | %m%n
>>> log4j.appender.sift.appender.**file=${karaf.data}/log/$\\{bun**dle.name<http://bundle.name>
>>> \\}.log
>>> log4j.appender.sift.appender.**append=true
>>> log4j.logger.org.apache.camel = INFO
>>>
>>>
>>> I'm not sure how to create one here as well as in my code to properly
>>> have
>>> it use one of these appenders.  Sorry for being a newb!
>>>
>>> --
>>> View this message in context:
>>> http://camel.465427.n5.nabble.**com/Writing-the-servicemix-**
>>> log-within-custom-java-**tp5166486p5166698.html<http://camel.465427.n5.nabble.com/Writing-the-servicemix-log-within-custom-java-tp5166486p5166698.html>
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
> --
> Jean-Baptiste Onofré
> jbono...@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

Reply via email to