Logging is the process of printing out run-time information to the console or to a file. In the context of Red5 Pro, logging occurs at the global server level and or the applicaiton level by using custom logback files. In this tutorial, we will be adding custom logging to our example application that we have been building throughout this series.
If you have not done so already, register for an account at https://account.red5pro.com.
* A Trial Account allows for up to 10 concurrent connections, while the Professional license has no connection limit.
The following are required to setup the Red5 Pro Server and to follow along with this example:
The Red5 Pro server requires Java 1.7+ or higher. Install Java 1.7+ or higher if not already installed on your machine.
cdinto your Red5 Pro install directory and issue this command:
./red5.sh• On Windows: Navigate to the Red5 Pro install directory in a File Browser and double-click on
For the examples, we will be demonstrating how to set up the project in the Eclipse IDE. The steps for setup should be transferrable to the IDE of your choice, as it is the code and method of deployment that we will be more focused on.
The source for this example can be checked out from the following Github repository: https://github.com/red5pro/red5pro-dev-series.git
This documentation has an accompanying video walk through that you can follow as you are developing.
In this section, you will setup your workspace by cloning the github repository and set up Eclipse.
Add the following contents to the file
"1.0" encoding="UTF-8" xml version=<configuration scan="true" scanPeriod="5 seconds"> <contextName>example</contextName> <jmxConfigurator contextName="example" /> <appender name="EXAMPLE_APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>log/example.log</File> <Append>true</Append> <Encoding>UTF-8</Encoding> <BufferedIO>false</BufferedIO> <ImmediateFlush>true</ImmediateFlush> <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> <FileNamePattern>example.%i.log</FileNamePattern> <MinIndex>1</MinIndex> <MaxIndex>10</MaxIndex> </rollingPolicy> <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <MaxFileSize>5MB</MaxFileSize> </triggeringPolicy> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern>%msg%n</pattern> </encoder> </appender> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>[%p] [%thread] %logger - %msg%n</pattern> </encoder> </appender> <root> <level value="DEBUG" /> <appender-ref ref="CONSOLE" /> <appender-ref ref="EXAMPLE_APPENDER" /> </root> <logger name="com.red5pro.example" level="DEBUG"> <appender-ref ref="CONSOLE" /> <appender-ref ref="EXAMPLE_APPENDER" /> </logger> </configuration>
Add the following code inside of the appStart method.
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); Runnable task = () -> log.debug("Scheduling: " + System.nanoTime()); int initialDelay = 0; int period = 1; executor.scheduleAtFixedRate(task, initialDelay, period, TimeUnit.SECONDS);
tail -f -n 100 example.log
Congratulations! You have just added connection custom application level logs to your example Red5 Pro Server Application!
The following sections may aide in troubleshooting any issues may come across in trying the previous examples.
If you have further questions, please contact us at firstname.lastname@example.org
The following default ports are required to be open in order to allow for Live Streaming and Second Screen: