No announcement yet.

Per Channel Log Files In Mirth Channels

  • Filter
  • Time
  • Show
Clear All
new posts

  • Per Channel Log Files In Mirth Channels

    It is often useful to have a set of logs file per channel and to also log the name of the channel for every message logged. Not only does this make debugging easier it makes it easy to track production issues proactively. You can do this with log4j appenders using the configuration file as follows: (windows OS)

    Lets say you want to add a log file to track DEBUG LEVEL message for a specific channel.

    1. open C:\Program Files\Mirth Connect\conf\

    2. Add the following just after the 'log4j.appender.fout.layout.ConversionPattern:' setting in your default log4j file (you can tune the appender properties to your liking)

    dir.logs = C:\\Mirth Connect\\logs #this is already present in default file.

    log4j.logger.myLogger=DEBUG, mylogger
    log4j.appender.mylogger=org.apache.log4j.RollingFi leAppender
    log4j.appender.mylogger.layout=org.apache.log4j.Pa tternLayout
    log4j.appender.mylogger.layout.ConversionPattern=% d{yyyy-MM-dd HH:mm:ss} %c : %m%n

    3. In your channel log to this file as :

    var channelName = nelController.getInstance().getDeployedChannelById (channelId).getName();

    logger.getLogger("myLogger").error(channelName + "CustomMessage");

    4. Deploy your channel after changes in #3. Stop and start Mirth service so take effect. start the channel with the logging code in #3

    5. You should see the new log file appear in :

    C:\Mirth Connect\logs\seconf_file.log

  • #2
    nice hint!
    I'd like just to suggest to put also a false clause to your logger addictivity clause, unless you want all the logs to go also to the standard mirth log file

    log4j.additivity.myLogger = false

    And, of, course, if you don't care of repeating channel name in the log file, you can simply write in any javascript transformer

    var myLog=logger.getLogger("myLogger");



    • #3
      This may also be useful to you:
      Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

      Nicholas Rupley
      Work: 949-237-6069
      Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.

      - How do I foo?
      - You just bar.


      • #4
        You also might want to have a look at this thread which adds per-channel logging on the fly without having to change log4j configuration for each channel.