I think I must be doing something wrong. Hopefully one of the PAX folks can help here. I wonder if I should just reach out to them directly or if this is a karaf-specific issue with PAX?
On Wed, May 24, 2017 at 2:29 PM Matt Sicker <boa...@gmail.com> wrote: > At compile time, an annotation processor in log4j-core generates a .dat > file containing some metadata about scanned plugins. These JAR resource > files are loaded at plugin scan time where reflection is used to > investigate the classes and instantiate plugins based on config files. > Alternatively, there's an option you can set to scan a particular list of > packages for additional plugins, though I think that uses the context > ClassLoader which might not work properly in your scenario. > > On 24 May 2017 at 11:22, James Carman <ja...@carmanconsulting.com> wrote: > > > Any advice on how I might be able to fight my way through it? How does > > Log4j2 "discover" those @Plugin-annotated classes? Does it use some form > > of classpath scanning? Is it scoped to certain packages only? I'm > > thinking I might have to attach to the pax-logging-log4j2 bundle as a > host > > in order to augment its classpath so that it can see my stuff. > > > > On Wed, May 24, 2017 at 12:20 PM Matt Sicker <boa...@gmail.com> wrote: > > > > > It could be a bug in log4j2 itself rather than pax-logging. I worked on > > > some OSGi support in log4j2 a while back, and I'm not sure if this is a > > new > > > issue or an existing one. > > > > > > On 24 May 2017 at 05:43, James Carman <ja...@carmanconsulting.com> > > wrote: > > > > > > > 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 < > > ja...@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? > > > > > > > > > > > > > > > > > > > > > -- > > > Matt Sicker <boa...@gmail.com> > > > > > > > > > -- > Matt Sicker <boa...@gmail.com> >