red5 1.0.0 rc1:配置 logback 以记录来自 org.red5.server.service.ServiceInvoker 的错误
这是我的 logback 配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<contextName>xpofacebook</contextName>
<appender name="ERROR"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/xpofacebook-error.log</File>
<Append>true</Append>
<BufferedIO>false</BufferedIO>
<ImmediateFlush>true</ImmediateFlush>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</Pattern>
</layout>
<rollingPolicy
class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>log/error.log.%i.zip</FileNamePattern>
<MinIndex>1</MinIndex>
<MaxIndex>3</MaxIndex>
</rollingPolicy>
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>5MB</MaxFileSize>
</triggeringPolicy>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
</appender>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/xpofacebook-application.log</File>
<Append>true</Append>
<BufferedIO>false</BufferedIO>
<ImmediateFlush>true</ImmediateFlush>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%date{ISO8601} [%-5level] %logger{35} - %msg%n</Pattern>
</layout>
<rollingPolicy
class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>log/xpofacebook-application.log.%i.zip</FileNamePattern>
<MinIndex>1</MinIndex>
<MaxIndex>3</MaxIndex>
</rollingPolicy>
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>5MB</MaxFileSize>
</triggeringPolicy>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="ERROR" />
<appender-ref ref="FILE" />
</root>
</configuration>
到目前为止效果很好 我需要将以下代码添加到我想要记录消息的每个类:
private static Logger log = Red5LoggerFactory.getLogger(ClassName.class, "xpofacebook");
我希望主日志文件 xpofacebook-application.log 记录我使用的类之外的消息。
如果 Flex 客户端连接到 red5 服务器并尝试调用不存在的命令,则会显示以下错误消息:
[NioProcessor-1] org.red5.server.service.ServiceInvoker - Method
getLiveChallenges with parameters [] not found in
com.xpogames.xpofacebook.Application@55e03a61
How can i makesure that those type of error messages will be include in my log file as well ?
This is my logback configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<contextName>xpofacebook</contextName>
<appender name="ERROR"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/xpofacebook-error.log</File>
<Append>true</Append>
<BufferedIO>false</BufferedIO>
<ImmediateFlush>true</ImmediateFlush>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</Pattern>
</layout>
<rollingPolicy
class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>log/error.log.%i.zip</FileNamePattern>
<MinIndex>1</MinIndex>
<MaxIndex>3</MaxIndex>
</rollingPolicy>
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>5MB</MaxFileSize>
</triggeringPolicy>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
</appender>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/xpofacebook-application.log</File>
<Append>true</Append>
<BufferedIO>false</BufferedIO>
<ImmediateFlush>true</ImmediateFlush>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%date{ISO8601} [%-5level] %logger{35} - %msg%n</Pattern>
</layout>
<rollingPolicy
class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>log/xpofacebook-application.log.%i.zip</FileNamePattern>
<MinIndex>1</MinIndex>
<MaxIndex>3</MaxIndex>
</rollingPolicy>
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>5MB</MaxFileSize>
</triggeringPolicy>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="ERROR" />
<appender-ref ref="FILE" />
</root>
</configuration>
so far it works great
i need to add the following code to each class that i want to log messages in:
private static Logger log = Red5LoggerFactory.getLogger(ClassName.class, "xpofacebook");
i want the main log file xpofacebook-application.log to log messages outside of the classes that i work with.
If a flex client is connected to the red5 server and is trying to invoke a command that does not exist, the following error message will be show:
[NioProcessor-1] org.red5.server.service.ServiceInvoker - Method
getLiveChallenges with parameters [] not found in
com.xpogames.xpofacebook.Application@55e03a61
How can i make sure that these type of error messages will be included in my log file as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这将改变 Red5 的核心日志功能。现在,应用程序外部的内容由不同的记录器控制,因为它们属于您上方的类加载器。在这里,我不会深入探讨 Java 类加载器的乐趣,我只是简单地说,最终会出现修复或解决方法。
This will take a change in the core logging functionality of Red5. Right now the stuff outside your application is controlled by a different logger because they fall within a classloader above yours. Without getting into the fun of Java classloaders here, I will simply say that a fix or workaround will eventually come.