Log4j logs in osgi

Source: Internet
Author: User
1. log4j. properties example
Log4j. rootcategory = info, stdout, logfile

Log4j. appender. stdout = org. Apache. log4j. leleappender
Log4j. appender. stdout. layout = org. Apache. log4j. patternlayout
Log4j. appender. stdout. layout. conversionpattern = % d % P [% C]-<% m> % N

Log4j. appender. logfile = org. Apache. log4j. dailyrollingfileappender
Log4j. appender. logfile. File = text_log.log
Log4j. appender. logfile. datepattern =. yyyy-mm-dd
Log4j. appender. logfile. layout = org. Apache. log4j. patternlayout
Log4j. appender. logfile. layout. conversionpattern = % d % P [% C]-<% m> % N

Needless to say, there are two points worth attention.
Log4j. rootcategory = info, followed by upper case. If it is written in lower case, the default value is info.
Log4j. appender. logfile. File = text_log.log. This is the file that generates the log result. The address of this file is relative to the jar package that starts main.
For example, in the development status, the root directory of eclipse and the directory where the project is packaged and * osgi *. Jar (main osgi package) is located.

Question about how to place log4j. properties during osgi Development
A. log4j. osgi-1.2.15-SNAPSHOT.jar. (Spring2.5.1 + spring dm1.0.2) and load this bundle when starting the system
B. Configure parameters (more user-friendly)
Set in startup parameters (in eclipse or packaged run. BAT)
Java-dorg. osgi. Service. http. Port = 8096-jar osgi3.2.1.jar-configuration-dlog4j. Configuration = file: config/log4j. properties-Console
Note:
-Dorg. osgi. Service. http. Port: the jetty port is used when the system starts.
-Jar: osgi MAIN package address
-Configuration: Use the config. ini file in the specified directory as the system startup configuration.
-Dlog4j. Configuration: the address of the log4j log configuration file, which can be a relative path. For example, the above indicates that the log4j configuration file is placed in the config under the main () package directory.
-Console: Start the system on the console.

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.