You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by "munishgupta.asr" <mu...@gmail.com> on 2019/02/19 12:40:29 UTC
how to change log42.xml configuration from karaf command
Hi,
Earlier with Log4J, we used to change "org.ops4j.pax.logging.cfg" for
changing any configuration like compression etc by using karaf commands.
config:edit org.ops4j.pax.logging
property-set <set property here>
config:update
with Log4J2, now entire configuration is in log4j2.xml and
org.ops4j.pax.logging.cfg has just one entry which is
org.ops4j.pax.logging.log4j2.config.file=etc/log4j2.xml
I have to enable/disable compression at run time by changing filePattern
defined in log42.XML.
can i manipulate log42.xml directly by using karaf commands now?
Regards
Munish
--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Re: how to change log42.xml configuration from karaf command
Posted by "munishgupta.asr" <mu...@gmail.com>.
Hi JB,
In Log4J2,.XML, I was using pattern layout and it has %spi%n to have some
masking logic before logging. I have written plugin's which extend
LogEventPatternConverter to do some masking before logging.
I have added some additional headers / footers also through plugin's.
<PatternLayout>
<Pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} CEF:1 |
%X{bundle.name} | %X{bundle.version} | %-5.5p | ID=%X{bundle.id}
THR=%-16.16t CAT=%-32.32c{1} MSG=%spi%n</Pattern>
<Header>BEMS Version ${BEMS_VERSION}
hostname=${hostName} now=%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ}%n%H%n</Header>
<Footer>BEMS Version ${BEMS_VERSION}
hostname=${hostName} now=%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ}%n</Footer>
</PatternLayout>
@Plugin(name = "LogRedactConverter", category = "Converter")
@ConverterKeys({"spi"})
public class LogRedactConverter extends LogEventPatternConverter
@Plugin(name = "LogHeaderConverter", category = "Converter")
@ConverterKeys({"H", "v"})
public class LogHeaderConverter extends LogEventPatternConverter
With CFG files, I don't see these conversion specifiers getting recognized.
ERROR Unrecognized conversion specifier [spi] starting at position 141 in
conversion pattern.
I changed it like this.
log4j2.pattern = %d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} CEF:1 | %X{bundle.name} |
%X{bundle.version} | %-5.5p | ID=%X{bundle.id} THR=%-16.16t CAT=%-32.32c{1}
MSG=%spi%n
is there any limitation here or it is my configuration issue with CFG file.
Regards
Munish
--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Re: how to change log42.xml configuration from karaf command
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Munish,
log4j2 backend with pax-logging doesn't mean you have to use XML
configuration format.
Using config.file with XML has two limitations:
1. It doesn't reload automatically when you change the XML, you have to
reload pax logging
2. You can't change the XML directly using config:* commands
Instead of log4j2 XML, you can use directly the cfg pax logging log4j2
backend: it's what you have by default in Karaf 4.2.x.
For instance, here's the default pax logging log4j2 configuration:
https://github.com/apache/karaf/blob/master/assemblies/features/base/src/main/resources/resources/etc/org.ops4j.pax.logging.cfg
Do you really need log4j2 XML configuration ?
Regards
JB
On 19/02/2019 13:40, munishgupta.asr wrote:
> Hi,
>
> Earlier with Log4J, we used to change "org.ops4j.pax.logging.cfg" for
> changing any configuration like compression etc by using karaf commands.
> config:edit org.ops4j.pax.logging
> property-set <set property here>
> config:update
>
> with Log4J2, now entire configuration is in log4j2.xml and
> org.ops4j.pax.logging.cfg has just one entry which is
> org.ops4j.pax.logging.log4j2.config.file=etc/log4j2.xml
>
> I have to enable/disable compression at run time by changing filePattern
> defined in log42.XML.
>
> can i manipulate log42.xml directly by using karaf commands now?
>
> Regards
> Munish
>
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com