karaf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Carman <ja...@carmanconsulting.com>
Subject Re: Using Custom Layout for Log4j2 in Karaf 4.1.x...
Date Wed, 24 May 2017 10:43:36 GMT
I tried adding pax-logging-service to startup.properties (after putting it
into the system repo) and I still have the issue. So, the ultimate issue
isn't the fragment host necessarily. My issue is that it can't fine my
custom layout class. I've tried using the name from the @Plugin annotation.
I've tried using the fully-qualified class name. Nothing seems to work.
Here's the declaration of my layout:

@Plugin(name = "MyJsonLayout", category = Node.CATEGORY, elementType =
Layout.ELEMENT_TYPE, printObject = true)
public class MyJsonLayout extends AbstractStringLayout {
...
}

and here's what I've changed in the logging config file:

log4j2.rootLogger.appenderRef.RollingFile.ref = RollingFile
# Rolling file appender
log4j2.appender.rolling.type = RollingRandomAccessFile
log4j2.appender.rolling.name = RollingFile
log4j2.appender.rolling.fileName = ${karaf.home}/log/aetos.log
log4j2.appender.rolling.filePattern = ${karaf.home}/log/aetos.log.%i
# uncomment to not force a disk flush
log4j2.appender.rolling.immediateFlush = false
log4j2.appender.rolling.append = true
log4j2.appender.rolling.layout.type = com.myco.log4j.json.MyJsonLayout
log4j2.appender.rolling.policies.type = Policies
log4j2.appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.rolling.policies.size.size = 200MB

As I said, I tried just using layout.type = MyJsonLayout, but that doesn't
work either.  Do we have an example where something like this works that I
can reverse engineer?

Thanks,

James

On Tue, May 23, 2017 at 7:03 PM James Carman <james@carmanconsulting.com>
wrote:

> I am trying to use a custom layout and I'm following the examples (I
> think).  We had one that worked in Karaf 3.0.x.  Anyway, I set up the
> fragment host like this:
>
> <plugin>
>   <groupId>org.apache.felix</groupId>
>   <artifactId>maven-bundle-plugin</artifactId>
>   <version>3.3.0</version>
>   <extensions>true</extensions>
>   <inherited>true</inherited>
>   <configuration>
>     <instructions>
>
> <Fragment-Host>org.ops4j.pax.logging.pax-logging-service</Fragment-Host>
>     </instructions>
>   </configuration>
> </plugin>
>
> However, my bundle will not resolve this way. I don't see that bundle
> being loaded in Karaf 4.1.1:
>  karaf@root()> list -t 0 -s | grep -i log 19:01:18
>  5 │ Active │ 8 │ 1.9.1 │ org.ops4j.pax.logging.pax-logging-api
>  6 │ Active │ 8 │ 1.9.1 │ org.ops4j.pax.logging.pax-logging-log4j2
> 36 │ Active │ 30 │ 4.1.1 │ org.apache.karaf.log.core
>
> I tried binding to "org.ops4j.pax.logging.pax-logging-api", but that
> didn't work either.  Did this process change for 4.1.x?
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message