Log4j 2
  1. Log4j 2
  2. LOG4J2-314

How to create multiple appenders at runtime, sharing an AsyncAppender?

    Details

    • Type: Question Question
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Appenders, Configurators
    • Labels:
      None

      Description

      I have a log4j2.xml configuration file from which I am getting the Logger, attached is the snapshot. when my logger is created a new thread is created.

      Programmatically,I create a RollingFileAppender and attach the it to AsyncAppender . I attach the Async Appender to the configuration of the log4j.xml, And when I start the Async Appender again a new thread is created.

      Is this a bug? because I get a logger a new thread is generated and when I create a async appender another thread is created and both are doing the same job.

      Also there is already a asyncappender in my log4j2.xml and I am creating one via program. Will this cause a problem? I did this because I am currently unable to hook my programmatically created appender to the AsyncAppender defined in log4j2.xml.

      1. asyncAppendThread.png
        23 kB
        Sudharma Puranik
      2. log4j2.xml
        2 kB
        Sudharma Puranik
      3. loggerThread.png
        44 kB
        Sudharma Puranik
      4. TestAppender.zip
        736 kB
        Sudharma Puranik

        Activity

        Sudharma Puranik created issue -
        Sudharma Puranik made changes -
        Field Original Value New Value
        Attachment asyncAppendThread.png [ 12593127 ]
        Attachment loggerThread.png [ 12593128 ]
        Attachment log4j2.xml [ 12593129 ]
        Sudharma Puranik made changes -
        Description I have a log4j2.xml configuration file from which I am getting the Logger, attached is the snapshot. when my logger is created a new thread is created.

        Programmatically,I create a RollingFileAppender and attach the same to AsyncAppender . I attach the Async Appender to the configuration of the log4j.xml, And when I start the Async Appender again a new thread is created.


        Is this a bug? because I get a logger a new thread is generated and when I create a async appender another thread is created and both are doing the same job.

         Also there is already a asyncappender in my log4j2.xml and I am creating one via program. Will this cause a problem? I did this because I am currently unable to hook my programmatically created appender to the AsyncAppender defined in log4j2.xml.
        I have a log4j2.xml configuration file from which I am getting the Logger, attached is the snapshot. when my logger is created a new thread is created.

        Programmatically,I create a RollingFileAppender and attach the it to AsyncAppender . I attach the Async Appender to the configuration of the log4j.xml, And when I start the Async Appender again a new thread is created.


        Is this a bug? because I get a logger a new thread is generated and when I create a async appender another thread is created and both are doing the same job.

         Also there is already a asyncappender in my log4j2.xml and I am creating one via program. Will this cause a problem? I did this because I am currently unable to hook my programmatically created appender to the AsyncAppender defined in log4j2.xml.
        Sudharma Puranik made changes -
        Attachment TestAppender.zip [ 12593150 ]
        Sudharma Puranik made changes -
        Attachment TestAppender.zip [ 12593151 ]
        Sudharma Puranik made changes -
        Comment [ Attached is the zip file. the log files are generated at /logs/test.log. ]
        Sudharma Puranik made changes -
        Attachment TestAppender.zip [ 12593150 ]
        Sudharma Puranik made changes -
        Attachment TestAppender.zip [ 12593151 ]
        Sudharma Puranik made changes -
        Attachment TestAppender.zip [ 12593154 ]
        Remko Popma made changes -
        Summary Multiple thread creation problem with AsyncAppender How to create multiple appenders at runtime, sharing an AsyncAppender?
        Remko Popma made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Sudharma Puranik
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development