You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Remko Popma (JIRA)" <ji...@apache.org> on 2014/01/05 13:41:55 UTC
[jira] [Assigned] (LOG4J2-463) Configuration sample MyApp does not
compile
[ https://issues.apache.org/jira/browse/LOG4J2-463?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Remko Popma reassigned LOG4J2-463:
----------------------------------
Assignee: Remko Popma
> Configuration sample MyApp does not compile
> -------------------------------------------
>
> Key: LOG4J2-463
> URL: https://issues.apache.org/jira/browse/LOG4J2-463
> Project: Log4j 2
> Issue Type: Bug
> Components: Documentation
> Reporter: Michael Diamond
> Assignee: Remko Popma
> Attachments: LOG4J2-463.patch
>
>
> The {{MyApp}} example application in the [Automatic Configuration|http://logging.apache.org/log4j/2.x/manual/configuration.html#AutomaticConfiguration] section does not compile.
> 1. {{LogManager}} is not imported
> 2. {{logger}} is not {{static}}
> 3. {{!bar.doIt()}} conditional missing a close-paren
> 4. {{com.foo.Bar}} is similarly missing the {{LogManager}} import
> Less critical, but the formatting/indentation of this example code is also poor, which could be confusing.
> {{MyApp.java}} with fixes:
> {noformat}
> import com.foo.Bar;
> //Import log4j classes.
> import org.apache.logging.log4j.LogManager;
> import org.apache.logging.log4j.Logger;
> public class MyApp {
> // Define a static logger variable so that it references the
> // Logger instance named "MyApp".
> static Logger logger = LogManager.getLogger(MyApp.class.getName());
>
> public static void main(String[] args) {
> // Set up a simple configuration that logs on the console.
> logger.trace("Entering application.");
> Bar bar = new Bar();
> if (!bar.doIt()) {
> logger.error("Didn't do it.");
> }
> logger.trace("Exiting application.");
> }
> }
> {noformat}
> {{Bar.java}} with fixes:
> {noformat}
> package com.foo;
> import org.apache.logging.log4j.LogManager;
> import org.apache.logging.log4j.Logger;
> public class Bar {
> static Logger logger = LogManager.getLogger(Bar.class.getName());
>
> public boolean doIt() {
> logger.entry();
> logger.error("Did it again!");
> return logger.exit(false);
> }
> }
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org