You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by abdelb <ab...@live.co.uk> on 2020/02/10 02:02:17 UTC
Karaf 4.2.4 - Logging from class to file gets rid of all logging to
STDOUT
I want to capture logs (level: INFO) from a class to a file, but when I do
this, the STDOUT logs no longer appear in Karaf.
Is there a way to capture STDOUT logs from a bundle to a file? The logging
comes from a library used in the bundle. Why do they no longer appear?
My log4j2 is below:
/# Logger for recording BBGVCON trade messages
log4j2.logger.myApp.name = myApp.myClass
log4j2.logger.myApp.level = INFO
log4j2.logger.myApp.additivity = false
log4j2.logger.myApp.appenderRef.myAppDailyRollingFile.ref =
myAppDailyRollingFile
log4j2.appender.myApp.type = RollingFile
log4j2.appender.myApp.name = myAppDailyRollingFile
log4j2.appender.myApp.fileName = /var/mw/logs/${environment}/INFO.txt
log4j2.appender.myApp.filePattern =
/var/mw/logs/${environment}/INFO.txt.%d{dd-MM-yyyy}
log4j2.appender.myApp.append = true
log4j2.appender.myApp.layout.type = PatternLayout
log4j2.appender.myApp.layout.pattern = %m%n
log4j2.appender.myApp.policies.type = Policies
log4j2.appender.myApp.policies.time.type = TimeBasedTriggeringPolicy
log4j2.appender.myApp.policies.time.interval = 1
log4j2.appender.myApp.policies.time.modulate = true/
Thanks!
--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Re: Karaf 4.2.4 - Logging from class to file gets rid of all logging
to STDOUT
Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Hi,
You mean that you have System.out.println statements in the bundle right ?
If you start with bin/karaf, this output will go on the shell.
If it’s not possible to « pipe » directly stdout to a log file with log4j2 (or eventually we can create a custom appender for that), in Karaf you can set KARAF_REDIRECT in bin/setenv.
Then stdout and stderr with be catched and sent to a file.
It’s especially interesting when you start karaf with bin/start.
If you start Karaf with the wrapper, then, the wrapper send stdout/stderr to a file as well.
Regards
JB
> Le 10 févr. 2020 à 03:02, abdelb <ab...@live.co.uk> a écrit :
>
> I want to capture logs (level: INFO) from a class to a file, but when I do
> this, the STDOUT logs no longer appear in Karaf.
>
> Is there a way to capture STDOUT logs from a bundle to a file? The logging
> comes from a library used in the bundle. Why do they no longer appear?
>
> My log4j2 is below:
>
> /# Logger for recording BBGVCON trade messages
> log4j2.logger.myApp.name = myApp.myClass
> log4j2.logger.myApp.level = INFO
> log4j2.logger.myApp.additivity = false
> log4j2.logger.myApp.appenderRef.myAppDailyRollingFile.ref =
> myAppDailyRollingFile
> log4j2.appender.myApp.type = RollingFile
> log4j2.appender.myApp.name = myAppDailyRollingFile
> log4j2.appender.myApp.fileName = /var/mw/logs/${environment}/INFO.txt
> log4j2.appender.myApp.filePattern =
> /var/mw/logs/${environment}/INFO.txt.%d{dd-MM-yyyy}
> log4j2.appender.myApp.append = true
> log4j2.appender.myApp.layout.type = PatternLayout
> log4j2.appender.myApp.layout.pattern = %m%n
> log4j2.appender.myApp.policies.type = Policies
> log4j2.appender.myApp.policies.time.type = TimeBasedTriggeringPolicy
> log4j2.appender.myApp.policies.time.interval = 1
> log4j2.appender.myApp.policies.time.modulate = true/
>
> Thanks!
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html