king
I'm new here

Module specific logging and log4j

In FirstSpirit modules, there is a possibility to use module specific logging via:

FileHandle handle = environment.getLogDir().obtain("...");

In cases, where this solution is used, a module specific implementation of:

  • log4j
  • SLF4J
  • logging framework

is requested and needed.

We just wonder, how to integrate a logging framework with the above FirstSpirit FileHandle-object, where only "append" methods are given. For "log4j", individual appenders might be configured, that not necessarily write to a file each. How to combine it with FirstSpirit's "FileHandle" object.

0 Kudos
3 Replies
andre
I'm new here

if you need to log a lot and you need a special framework for that for any reason. you have to build your own (Remote)-Logging-Service which logs to the moduls logdir.

if you need no separated log-Files another way is to use de.espirit.common.base.Logging

--

andré

0 Kudos

Hi André,

is it a must-have, to integrate a log-framework when using the module specific log directory?

If no, how to log to it? Could you show an pseudo-code?

0 Kudos

no, it is not a must have.

if you want to integrate a log framework your self. the way to do this is to write a FS-(Remote)LoggingService-Modul

if you want to use firstSpirit capabilities use the FileHandle which does the remote stuff for you:

final FileHandle handle = _environment.getLogDir().obtain("yourLogFileName.log");

is = new ByteArrayInputStream("[prepend some date...] my log line".getBytes("UTF-8"));

handle.append(is);