OSGi + camel + KARAF configuration log output

Source: Internet
Author: User
Tags log4j

A simple example of Felix was compiled in the previous blog post, and then the example was started and the console output was activator after startup, but the entire example These bundles were not demonstrated during the boot process of the feature, and the process is demonstrated next.

Configuration Log

First, the output of the Karaf is log output, previously configured in the parent module Pom.xml the plug-in to specify the configuration file location, as follows:

 <plugin>                    <groupId>Org.apache.maven.plugins</groupId>                    <artifactid>Maven-resources-plugin</artifactid>                    <extensions>True</Extensions>                    <executions>                        <execution>                            <ID>Copy-resources</ID>                            <phase>Install</phase>                            <goals>                                <goal>Copy-resources</goal>                            </goals>                            <configuration>                                <outputdirectory>target/assembly</outputdirectory>                                <overwrite>True</overwrite>                                <resources>                                    <resource>                                        <directory>.. /.. /assembly/develop</directory>                                        <filtering>False</filtering>                                    </Resource>                                    <resource>                                        <directory>Src/test/resources</directory>                                        <filtering>False</filtering>                                    </Resource>                                </Resources>                            </configuration>                        </Execution>                    </executions>                </plugin>
<resource>                                        <directory>../../assembly/develop</directory>                                        <filtering>false</filtering></resource>

This is the specified global profile location, and the following is a single configuration file that specifies each module, such as a data source unique to each module, and so on.

<resource>                                        <directory>src/test/resources</directory>                                        <filtering>false</filtering></resource>

After the above configuration is completed, in the corresponding root directory to create the relevant folder, add a configuration file named Org.ops4j.pax.logging.cfg, this file does not know can be queried on google alone, This is the specified Karaf log output and the format is determined.

Log format

Org.ops4j.pax.logging.cfg specific content is as follows:

################################################################################## Licensed to the Apache software Foundation (ASF) under one or more# contributor license agreements. See the NOTICE file distributed with# This work for additional information regarding copyright ownership.# The ASF licenses this file to you under the Apache License, Version 2.0# (the "License"); you are not a use of this file except in compliance with# The License. Obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## unless required by applicable or agreed to writing, software# Distributed under the License is distributed on a "as is" BASIS,# without warranties or CONDITIONS of any KIND, either express or implied.# See the License for the specific language governing permissions and# Limitations under the License.################################################################################## Root LoggerLog4j. Rootlogger=info, stdout, out, osgi:*log4j. Throwablerenderer=org. Apache. Log4j. Osgithrowablerenderer# CONSOLE Appender not used by defaultLog4j. Appender. StdOut=org. Apache. Log4j. ConsoleappenderLog4j. Appender. StdOut. Layout=org. Apache. Log4j. PatternlayoutLog4j. Appender. StdOut. Layout. Conversionpattern=%d{iso8601} | %-5.5P | %-16.16T | %-32.32c{1} | %X{Bundle. ID} - %X{Bundle. Name} - %X{Bundle. Version} | %m%n# File AppenderLog4j. Appender. out=org. Apache. Log4j. RollingfileappenderLog4j. Appender. out. Layout=org. Apache. Log4j. PatternlayoutLog4j. Appender. out. Layout. Conversionpattern=%d{iso8601} | %-5.5P | %-16.16T | %-32.32c{1} | %X{Bundle. ID} - %X{Bundle. Name} - %X{Bundle. Version} | %m%nlog4j. Appender. out. File=${karaf. Data}/log/karaf. LogLog4j. Appender. out. Append=truelog4j. Appender. out. MaxFileSize=1mblog4j. Appender. out. Maxbackupindex=Ten# Sift AppenderLog4j. Appender. Sift=org. Apache. Log4j. Sift. MdcsiftingappenderLog4j. Appender. Sift. Key=bundle. NameLog4j. Appender. Sift. Default=karaflog4j. Appender. Sift. Appender=org. Apache. Log4j. FileappenderLog4j. Appender. Sift. Appender. Layout=org. Apache. Log4j. PatternlayoutLog4j. Appender. Sift. Appender. Layout. Conversionpattern=%d{iso8601} | %-5.5P | %-16.16T | %-32.32c{1} | %m%nlog4j. Appender. Sift. Appender. File=${karaf. Data}/log/$\\{bundle. Name\\}. LogLog4j. Appender. Sift. Appender. Append=true

This specifies the exact format of the log output and the output of those content and levels.

Demonstrate

Now start Karaf again and observe the output log as shown in:

Now you can carefully review the contents of the log, do not have to worry about when the Karaf start failure does not know the problem, here the Karaf log output in the future integration CXF time there are specific applications, where Karaf log output is indeed more convenient.

# Observe bundles in Karaf

Go to the Assembly folder in Target in example, as shown in:

CMD console into the Bin folder above, enter Karaf.bat, enter the Karaf console,

Input command bundle:list
Look at all the install bundles in Karaf, as shown in:

You can see that the example has the highest start level of 100, which can be set in the Feature.xml file specified in the second blog post of the OSGi series, as follows:

<bundle start-level="100">mvn:${project.groupId}/example/${project.version}</bundle>

However, we generally do not need this high boot level, generally set a little lower on it.

In the figure, the state of example is active, indicating that the bundle is in normal install, and the other aspect proves that the activator is completely normal and the program demonstrates successfully.

Summarize

This article describes the specific log output of Karaf and the bundle install process, and the next blog post will continue to be written in Felix example.

OSGi + camel + KARAF configuration log output

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.