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 Matt Sicker <bo...@gmail.com> on 2014/09/25 19:57:27 UTC

Fwd: [2/6] git commit: LOG4J2-589 Added logging, minor improvements.

You figured out the category thing, right? It's because anything that's an
XML element has to be in the Core category (which is what the Core category
seems to be for).

---------- Forwarded message ----------
From: <rp...@apache.org>
Date: 25 September 2014 12:24
Subject: [2/6] git commit: LOG4J2-589 Added logging, minor improvements.
To: commits@logging.apache.org


LOG4J2-589 Added logging, minor improvements.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit:
http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/9f76d5eb
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/9f76d5eb
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/9f76d5eb

Branch: refs/heads/LOG4J2-589
Commit: 9f76d5eba818269aa5474207519b9b4d9e2e6448
Parents: 5427dea
Author: rpopma <rp...@apache.org>
Authored: Fri Sep 26 02:15:21 2014 +0900
Committer: rpopma <rp...@apache.org>
Committed: Fri Sep 26 02:17:58 2014 +0900

----------------------------------------------------------------------
 .../apache/logging/log4j/core/config/CustomLevelPlugin.java  | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9f76d5eb/log4j-core/src/main/java/org/apache/logging/log4j/core/config/CustomLevelPlugin.java
----------------------------------------------------------------------
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/CustomLevelPlugin.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/CustomLevelPlugin.java
index ba0a260..532e811 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/CustomLevelPlugin.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/CustomLevelPlugin.java
@@ -20,11 +20,12 @@ import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
 import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
 import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+import org.apache.logging.log4j.status.StatusLogger;

 /**
  * Custom Level object that is created via configuration.
  */
-@Plugin(name = "CustomLevel", category = "Core") // TBD: category="Level"
does not work... Why?
+@Plugin(name = "CustomLevel", category = "Core", printObject = true)
 public final class CustomLevelPlugin {

     private CustomLevelPlugin() {
@@ -38,11 +39,12 @@ public final class CustomLevelPlugin {
      * @return A Level object.
      */
     @PluginFactory
-    public static Level createLevel(
-// @formatter:off
+    public static Level createLevel(// @formatter:off
             @PluginAttribute("name") final String levelName,
             @PluginAttribute("intLevel") final int intLevel) {
         // @formatter:on
+
+        StatusLogger.getLogger().debug("Creating CustomLevel(name='{}',
intValue={})", levelName, intLevel);
         Level result = Level.forName(levelName, intLevel);
         return result;
     }




-- 
Matt Sicker <bo...@gmail.com>

Re: [2/6] git commit: LOG4J2-589 Added logging, minor improvements.

Posted by Remko Popma <re...@gmail.com>.
To be honest I'm still not really clear on that bit. I found some code that handles plug-ins of category "level" but that code works differently than I expect...

I will add some new questions in the Jira comments soon. 

Sent from my iPhone

> On 2014/09/26, at 2:57, Matt Sicker <bo...@gmail.com> wrote:
> 
> You figured out the category thing, right? It's because anything that's an XML element has to be in the Core category (which is what the Core category seems to be for).
> 
> ---------- Forwarded message ----------
> From: <rp...@apache.org>
> Date: 25 September 2014 12:24
> Subject: [2/6] git commit: LOG4J2-589 Added logging, minor improvements.
> To: commits@logging.apache.org
> 
> 
> LOG4J2-589 Added logging, minor improvements.
> 
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/9f76d5eb
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/9f76d5eb
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/9f76d5eb
> 
> Branch: refs/heads/LOG4J2-589
> Commit: 9f76d5eba818269aa5474207519b9b4d9e2e6448
> Parents: 5427dea
> Author: rpopma <rp...@apache.org>
> Authored: Fri Sep 26 02:15:21 2014 +0900
> Committer: rpopma <rp...@apache.org>
> Committed: Fri Sep 26 02:17:58 2014 +0900
> 
> ----------------------------------------------------------------------
>  .../apache/logging/log4j/core/config/CustomLevelPlugin.java  | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9f76d5eb/log4j-core/src/main/java/org/apache/logging/log4j/core/config/CustomLevelPlugin.java
> ----------------------------------------------------------------------
> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/CustomLevelPlugin.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/CustomLevelPlugin.java
> index ba0a260..532e811 100644
> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/CustomLevelPlugin.java
> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/CustomLevelPlugin.java
> @@ -20,11 +20,12 @@ import org.apache.logging.log4j.Level;
>  import org.apache.logging.log4j.core.config.plugins.Plugin;
>  import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
>  import org.apache.logging.log4j.core.config.plugins.PluginFactory;
> +import org.apache.logging.log4j.status.StatusLogger;
> 
>  /**
>   * Custom Level object that is created via configuration.
>   */
> -@Plugin(name = "CustomLevel", category = "Core") // TBD: category="Level" does not work... Why?
> +@Plugin(name = "CustomLevel", category = "Core", printObject = true)
>  public final class CustomLevelPlugin {
> 
>      private CustomLevelPlugin() {
> @@ -38,11 +39,12 @@ public final class CustomLevelPlugin {
>       * @return A Level object.
>       */
>      @PluginFactory
> -    public static Level createLevel(
> -// @formatter:off
> +    public static Level createLevel(// @formatter:off
>              @PluginAttribute("name") final String levelName,
>              @PluginAttribute("intLevel") final int intLevel) {
>          // @formatter:on
> +
> +        StatusLogger.getLogger().debug("Creating CustomLevel(name='{}', intValue={})", levelName, intLevel);
>          Level result = Level.forName(levelName, intLevel);
>          return result;
>      }
> 
> 
> 
> 
> -- 
> Matt Sicker <bo...@gmail.com>

Re: [2/6] git commit: LOG4J2-589 Added logging, minor improvements.

Posted by Ralph Goers <ra...@dslextreme.com>.
That isn’t quite accurate.

The category really identifies the set of Plugins that a specific caller of PluginManager wants.  For example, PattermLayout only wants PatternConverters, not Appenders, etc., the Interpolator only wants Lookups, Flume wants a SecretKey provider and the Configuration picks up most everything else (“Core”).

Ralph



On Sep 25, 2014, at 10:57 AM, Matt Sicker <bo...@gmail.com> wrote:

> You figured out the category thing, right? It's because anything that's an XML element has to be in the Core category (which is what the Core category seems to be for).
> 
> ---------- Forwarded message ----------
> From: <rp...@apache.org>
> Date: 25 September 2014 12:24
> Subject: [2/6] git commit: LOG4J2-589 Added logging, minor improvements.
> To: commits@logging.apache.org
> 
> 
> LOG4J2-589 Added logging, minor improvements.
> 
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/9f76d5eb
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/9f76d5eb
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/9f76d5eb
> 
> Branch: refs/heads/LOG4J2-589
> Commit: 9f76d5eba818269aa5474207519b9b4d9e2e6448
> Parents: 5427dea
> Author: rpopma <rp...@apache.org>
> Authored: Fri Sep 26 02:15:21 2014 +0900
> Committer: rpopma <rp...@apache.org>
> Committed: Fri Sep 26 02:17:58 2014 +0900
> 
> ----------------------------------------------------------------------
>  .../apache/logging/log4j/core/config/CustomLevelPlugin.java  | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9f76d5eb/log4j-core/src/main/java/org/apache/logging/log4j/core/config/CustomLevelPlugin.java
> ----------------------------------------------------------------------
> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/CustomLevelPlugin.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/CustomLevelPlugin.java
> index ba0a260..532e811 100644
> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/CustomLevelPlugin.java
> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/CustomLevelPlugin.java
> @@ -20,11 +20,12 @@ import org.apache.logging.log4j.Level;
>  import org.apache.logging.log4j.core.config.plugins.Plugin;
>  import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
>  import org.apache.logging.log4j.core.config.plugins.PluginFactory;
> +import org.apache.logging.log4j.status.StatusLogger;
> 
>  /**
>   * Custom Level object that is created via configuration.
>   */
> -@Plugin(name = "CustomLevel", category = "Core") // TBD: category="Level" does not work... Why?
> +@Plugin(name = "CustomLevel", category = "Core", printObject = true)
>  public final class CustomLevelPlugin {
> 
>      private CustomLevelPlugin() {
> @@ -38,11 +39,12 @@ public final class CustomLevelPlugin {
>       * @return A Level object.
>       */
>      @PluginFactory
> -    public static Level createLevel(
> -// @formatter:off
> +    public static Level createLevel(// @formatter:off
>              @PluginAttribute("name") final String levelName,
>              @PluginAttribute("intLevel") final int intLevel) {
>          // @formatter:on
> +
> +        StatusLogger.getLogger().debug("Creating CustomLevel(name='{}', intValue={})", levelName, intLevel);
>          Level result = Level.forName(levelName, intLevel);
>          return result;
>      }
> 
> 
> 
> 
> -- 
> Matt Sicker <bo...@gmail.com>