If you plan to use your own appenders, you need to create an OSGi bundle and attach it as a fragment to the bundle with a symbolic name of
org.ops4j.pax.logging.pax-logging-service. This way, the underlying logging system will be able to see and use your appenders. app
So for example you write a log4j appender:
class MyAppender extends AppenderSkeleton {
...
} dom
Then you need to package the appender in a jar with a Manifest like this: maven
Manifest:
Bundle-SymbolicName: org.mydomain.myappender
Fragment-Host: org.ops4j.pax.logging.pax-logging-service
... this
注 :system 目錄是相似於maven repository結構的文件夾 spa
Copy the new appender fragment into the ${karaf.home}/system directory. Karaf uses a virtual maven repository to access resources in the system
directory, so the jar path should use the standard maven groupId/artifactId/version/ convention, where the groupId is a directory structure. it
Edit ${karaf.home}/etc/startup.properties and add the new fragment bundle to the list before the pax-logging-service bundle. io
Restart karaf with a clean run to reload the system bundles, and now you can use the appender in your log4j config file like shown in the config
examples above. class