Skip to content

QFJ Logging

Baoying Wang edited this page Jan 26, 2018 · 7 revisions

Introduction

During QFJ run, it will print many logs.

note: Storage is a different aspect with Logging. Storage is the storing of the outbound sequence numbers, and outbound messages. The outbound messages are used on sequence gap, if peer request resend(note: admin meesages will be skipped).

What are logged

events, incoming messages, outgoing messages

Where are logged

Controlled by LogFactory and its configuration properties.

You need identify which LogFacotary is used (or to be used) in your source code, e.g. ScreenLogFactory, SL4JLogFactory, , FileLogFactory, JdbcLogFactory, or your own customized Log Factory, etc. Then check the related configuration attributes, see the configuration page - https://www.quickfixj.org/usermanual/1.6.4//usage/configuration.html

Which Log Factory should be used

Generally, I prefer SL4JLogFactory, especailly your application use SL4J too. It is not complex to define your own LogFactory. Just refer the exists factories implemntation.

Log Factory List

Provide some detail of severl Log Factory. I don't think JDBCLogFactory is useful in any scenario. If you hope to log to another box, Log4J support that.

SL4JLogFactory - I prefer SL4JLogFactory, especailly your application use SL4J too.

Recommended, since it support rolling over natively by configuration(e.g. via log4j2.xml) http://quickfix-j.364392.n2.nabble.com/rolling-log-files-td7579313.html

In source code of SL4JFactory, all are printed as info level, except error event(error level). The related category is quickfixj.event, quickfixj.msg.incoming, quickfixj.msg.outgoing. You could configure your log4j2.xml, like below:

  1. add related libs to classpath apache-log4j-extras-1.1.jar commons-io-2.5.jar (?) log4j-core-2.6.2.jar log4j-api-2.6.2.jar
    log4j-sl4j-impl-2.6.2.jar slf4j-api-1.6.4jar

  2. setup related log4j configuration file

You can setup below categories separately, or leave it with default(ROOT)

  • quickfixj.msg.incoming
  • quickfixj.msg.outgoing
  • quickfixj.event
  • note: they are printed at INFO level(some events are ERROR). If you hope to skip such logging, you have setup these category with warn+
  • the name of quickfixj.msg.incoming/quickfixj.msg.outgoing can be changed to other values, by change configuration "SLF4JLogIncomingMessageCategory", and "SLF4JLogOutgoingMessageCategory"

Skip the incoming/outgoing message logging, by setup them as warn. Just for reference here. see log4j2

    <Loggers>
        <Logger name="quickfixj.msg.incoming" level="warn"/> 
        <Logger name="quickfixj.msg.outgoing" level="warn"/>

see log4j(1.0)

  <category name="quickfixj.msg.incoming">
    <priority value="info"/>
  </category>  
  <category name="quickfixj.msg.outgoing">
    <priority value="info"/>
  </category>   

https://www.quickfixj.org/usermanual/1.6.4//usage/configuration.html https://logging.apache.org/log4j/2.x/manual/migration.html

  1. setup SLFJLogFactory, during Initiator and Acceptor

Refer:begin.FirstQFJClient, and begin.FirstQFJServer alreasy use SLFJLogFactory.

If you hope to switch off the msg incoming/outgoing(why?), you can change the priority to error(any better way?)

ScreenLogFactory - log on screen/console

If you just prepare a simple demo, you can just use ScreenLogFactory. It is straightforward.

attribute description value default
ScreenLogEvents Log events to screen. Y/N Y
ScreenLogShowIncoming Log incoming messages to screen. Y/N Y
ScreenLogShowOutgoing Log outgoing messages to screen. Y/N Y
ScreenLogShowHeartBeats Filter heartbeats from output (both incoming and outgoing) Y/N N

FileLogFactory - log to a file - not recommended. It does not support rolling over(until 1.6.0 at least)

It is straght forward to understand the attribute.

attribute description value default
FileLogPath Directory to store logs. Only used with FileLogFactory. valid directory for storing files, must have write access
FileLogHeartbeats Controls logging of heartbeat messages. Y/N Y
FileIncludeMilliseconds Controls whether milliseconds are included in log time stamps. Y/N Y
FileIncludeTimeStampForMessages Controls whether time stamps are included on message log entries. Y/N Y

Clone this wiki locally