Log Output from embedded PDF Renderer instances is a part of slf4j log handling set up in your application. Simply enable slf4j logging for instance classes such as com.priint.comet.renderer.pdf.Instance1
to get the output.
The default target for the logs depends on where your slf4j implementation setup redirects logs for used instance classes.
If your slf4j implementation of choice is logback, setting an explicitly configured target for Instance1 logs might be done by adding a block like the following into your logback settings:
<appender name="PDF-RENDERER-INSTANCE-1" class="ch.qos.logback.core.FileAppender"> <file>C:\comet\log\pdf-renderer-1.log</file> <encoder> <pattern>%d %p %c{1} [%t] %m%n</pattern> </encoder> </appender> <logger name="com.priint.comet.renderer.pdf.Instance1" level="INFO" additivity="false"> <appender-ref ref="PDF-RENDERER-INSTANCE-1" /> </logger>It's as simple as that...
Separate appenders may be attached to each Instance independently or a more general logger can be used to direct logs of all instances into the same appenders.
The LogLevel is automatically determined from each instances' org.slf4j.Logger object, this LogLevel is also applied to the native renderer instance (i.e.: messages with lower severity than supported by the logger are supressed). You can
By default, any log output (beside critical information, such as license order, which is written to stdout) of the InDesign® Server is suppressed.
Logging can be enabled by providing logger configuration to the InDesignServerFactory
upon Renderer
instance initialization.
Log output of InDesign® Server cannot just be redirected to a Java logger, but we can configure certain aspects of logging via a InDesignServerFactory.LogConfig
object.
InDesignServerFactory.LogConfig logConfig = new InDesignServerFactory.LogConfig( LogLevel.INFO, "testlog-$INSTANCE_NAME.log", "%d %p %c{1} [%t] %m%n"); Renderer renderer = Renderer.builder() .rendererFactory(new InDesignServerFactory(logConfig)) .handledDocumentType(InDesignDocumentType.class) .configuration( Configuration.create() .set(ConfigurationOption.BENCHMARK, true) .set(ConfigurationOption.FONT_POLICY, Options.FontMapping.USER_MAPPING | Options.FontMapping.DEFAULT_MAPPING | Options.FontMapping.BUILTIN_MAPPING) ) .build();Remarks
InDesignServerConfiguration config = new InDesignServerConfiguration("http://server.host:4711"); // name of log file in this case will be // testlog-hooky.log config.setName("hooky");
%t
will output the process ID rather than the thread name (because InDesign® is basically a single threaded application).
At least, using the same pattern as for Java loggers, the log output of InDesign® / Comet should be syntactically compatible to the output of the Java logger.
debug
, but the logger only supports info
level messages, the renderer will propagate debug messages to the Java Logger, but they are not written anyway.
You must
This is probably harder to explain, than to understand. The following example should give you an idea:
import org.slf4j.LoggerFactory; import com.priint.comet.renderer.EventChain; import com.priint.comet.renderer.LogLevel; import com.priint.comet.renderer.Renderer; import com.priint.comet.renderer.Subject; import com.priint.comet.renderer.exception.RendererException; public class ConfigureLogger { public void configureLogger() { try { // we assume, defaultLogger supports up to 'trace' level: org.slf4j.Logger defaultLogger = LoggerFactory.getLogger("my.default.logger"); Renderer.setLogger(defaultLogger); // initially we want the log level to be set to 'info'. // The CONNECT_BEFORE event is suitable for that purpose: Renderer.addObserver( (subject, instance, data) -> { instance.setLogLevel(LogLevel.INFO); return EventChain.CONTINUE; }, Subject.CONNECT_BEFORE); // when running a build command, we want the log level to be set to 'trace' Renderer.addObserver( (subject, instance, data) -> { instance.setLogLevel(LogLevel.TRACE); return EventChain.CONTINUE; }, Subject.BUILD_BEFORE); // ... and be reset afterwards Renderer.addObserver( (subject, instance, data) -> { instance.setLogLevel(LogLevel.INFO); return EventChain.CONTINUE; }, Subject.BUILD_AFTER); } catch (RendererException e) { } } }