Log4j 2
  1. Log4j 2
  2. LOG4J2-561

Allow spaces around commas in Configuration's package attribute

    Details

      Description

      Can anyone please explain how to add a new(custom) appender..?
      here is my code it did not work..

      @Plugin(name = "EM_Appender", category = "Core", elementType = "appender", printObject = true)
      public final class EventManagerAppender extends AbstractAppender{

      protected EventManagerAppender(String name, Filter filter, Layout<? extends Serializable> layout,
      boolean ignoreExceptions)

      { super(name, filter, layout, ignoreExceptions); // TODO Auto-generated constructor stub }

      /* @SuppressWarnings("rawtypes")
      private EventManagerAppender(String name, Layout layout, Filter filter,
      boolean ignoreExceptions) {

      }*/

      @PluginFactory
      public static EventManagerAppender createAppender(@PluginAttribute("name") String name,
      @PluginAttribute("ignoreExceptions") String ignore,
      @PluginElement("Layout") Layout layout,
      @PluginElement("Filters") Filter filter) {

      boolean ignoreExceptions = Boolean.parseBoolean(ignore);
      if (name == null)

      { return null; }

      if (layout == null)

      { layout = PatternLayout.createLayout(null, null, null, null, ignore, ignore); }

      return new EventManagerAppender(name, filter,layout, ignoreExceptions);
      }

      public void append(LogEvent event)

      { System.out.println(event.getMessage()); System.out.println("Custome appender"); }

      }

      XML configuration
      **********************
      <?xml version="1.0" encoding="UTF-8"?>
      <Configuration status="warn" strict="true" name="XMLConfigTest"
      packages="org.apache.logging.log4j.test,com.mycompany.abc.def.log.wrapper" monitorInterval="30">
      <Properties>
      <Property name="filename">C:/Logs/test1.log</Property>
      </Properties>
      <Filter type="ThresholdFilter" level="warn"/>

      <Appenders>
      <Appender type="File" name="File" fileName="$

      {filename}

      ">
      <Layout type="PatternLayout">
      <Pattern>%d

      {dd MMM yyyy HH:mm:ss,SSS}

      %-5p [%c

      {1}:%L:%t] %m%n</Pattern>
      </Layout>
      </Appender>
      <EM_Appender name="EM_Appender">
      <Layout type="PatternLayout">
      <Pattern>%d{dd MMM yyyy HH:mm:ss,SSS} %-5p [%c{1}

      :%L:%t] %m%n</Pattern>
      </Layout>
      </EM_Appender>
      </Appenders>

      <Loggers>
      <Logger name="com.mycompany.xyz.ab" level="trace" additivity="false">
      <AppenderRef ref="File"/>
      </Logger>

      <Root level="trace">
      <AppenderRef ref="File"/>
      <AppenderRef ref="EM_Appender"/>
      </Root>
      </Loggers>

      </Configuration>

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Gary Gregory
            Reporter:
            vibin
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development