Skip to content

How To Enable Debug Logs

mailmindlin edited this page Jan 15, 2016 · 1 revision

Debug logs in most cases are able to reveal us some secrets. By default those logs are disabled. This short instruction describes how to enable them.

Webcam Capture uses SLF4J as a logging wrapper, so if you are using any logging framework for which compatible SLF4J wrapper exists, you can enable debug logs in accordance to the instruction from this particular logging framework.

However, if you do not use any specific logging mechanism, or you are using Logback, then the following instruction is for you.

NOTE! Below method is compatible with Logback only.

1

Create logback.xml and drop it in the program working directory. Include this in the created file:

<configuration scan="true" scanPeriod="30 seconds">
	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
		<layout class="ch.qos.logback.classic.PatternLayout">
			<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
		</layout>
	</appender>
	<root level="debug">
		<appender-ref ref="STDOUT" />
	</root>
</configuration>

2

Download logback-core and logback-classic JARs and include them in your program's classpath.

3

Put this method at the very beginning of your main() method, before you use any Webcam Capture feature:

WebcamLogConfigurator.configure("logback.xml");

4

Run your program. In the console output you should see some debug logs, e.g.:

18:03:46.603 [capture-1] INFO  c.g.sarxos.webcam.WebcamDriverUtils - Searching driver com.github.sarxos.webcam.ds.openimaj.OpenImajDriver
18:03:46.619 [capture-1] DEBUG c.g.sarxos.webcam.WebcamDriverUtils - Driver com.github.sarxos.webcam.ds.openimaj.OpenImajDriver not found
18:03:46.619 [capture-1] INFO  c.g.sarxos.webcam.WebcamDriverUtils - Searching driver com.github.sarxos.webcam.ds.civil.LtiCivilDriver
18:03:46.619 [capture-1] DEBUG c.g.sarxos.webcam.WebcamDriverUtils - Driver com.github.sarxos.webcam.ds.civil.LtiCivilDriver not found
18:03:46.619 [capture-1] INFO  c.g.sarxos.webcam.WebcamDriverUtils - Searching driver com.github.sarxos.webcam.ds.jmf.JmfDriver
18:03:46.619 [capture-1] DEBUG c.g.sarxos.webcam.WebcamDriverUtils - Driver com.github.sarxos.webcam.ds.jmf.JmfDriver not found
18:03:46.619 [capture-1] INFO  com.github.sarxos.webcam.Webcam - Webcam driver has not been found, default one will be used!
18:03:46.619 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices

5

If you are using default or OpenIMAJ capture driver and would like to see logs from native layer, then set OPENIMAJ_GRABBER_VERBOSE environment variable to any value, e.g.:

OPENIMAJ_GRABBER_VERBOSE=true

On Windows you can set environment in My Computer / Preferences / Advanced / Environment Variables. On Linux and Mac OS I'm sure you already know how to do that :D

6

Run your application with additional JVM argument passed to the java command:

  • -Dwebcam.debug=true
  • -Dbridj.veryVerbose=true
  • -Dbridj.quiet=false
  • -Dbridj.logCalls=true
  • -Dbridj.debug=true

In Eclipse / Netbeans and other IDEs you can set this argument in the application runtime configuration.

From command line this should look like this:

C:\>set OPENIMAJ_GRABBER_VERBOSE=true
C:\>java -cp [jars] -Dwebcam.debug=true -Dbridj.veryVerbose=true -Dbridj.quiet=false -Dbridj.logCalls=true -Dbridj.debug=true [class]

Where [jars] must be replaced with all the JARs to be included in the classpath, and [class] must be replaced with your application main class.