Log4j and EAR conflicts with jboss - jboss

I have an EAR deployed on Jboss 4.2.3 with the following jboss-app.xml configuration file :
<jboss-app>
<loader-repository>
com.al6:loader=MyProject.ear
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</jboss-app>
And an application.xml file :
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"
version="1.4">
<description>Manages project business layer</description>
<display-name>MyProject</display-name>
<module>
<ejb>MyProject.jar</ejb>
</module>
</application>
And in my Jboss log file :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!-- ===================================================================== -->
<!-- -->
<!-- Log4j Configuration -->
<!-- -->
<!-- ===================================================================== -->
<!-- $Id: jboss-log4j.xml 75507 2008-07-08 20:15:07Z stan.silvert#jboss.com $ -->
<!--
| For more configuration infromation and examples see the Jakarta Log4j
| owebsite: http://jakarta.apache.org/log4j
-->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<!-- ================================= -->
<!-- Preserve messages in a local file -->
<!-- ================================= -->
<!-- A time/date based rolling appender -->
<appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="${jboss.server.log.dir}/server.log"/>
<param name="Append" value="false"/>
<param name="Threshold" value="INFO"/>
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
</layout>
</appender>
<!-- ============================== -->
<!-- Append messages to the console -->
<!-- ============================== -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="Target" value="System.out"/>
<param name="Threshold" value="INFO"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
</layout>
</appender>
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->
<root>
<priority value="INFO" />
<appender-ref ref="FILE"/>
</root>
</log4j:configuration>
Until now, all the logging output was using "System....println", which is not a good practice at all.
So, I tried to change to logger.info with :
protected org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(getClass());
But, after that, I'm not gonna had any log at all, nothing.
I tried to add a category in the jboss log configuration file, like :
<category name="com.myproject">
<priority value="INFO" />
<appender-ref ref="FILE"/>
</category>
But nothing change.
So I used my own log4j implementation observing a log4j.properties file which I can modify without redeploy :
package com.myproject;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardWatchEventKinds;
import java.nio.file.WatchEvent;
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
public class Log4jConfigurator implements Runnable {
private static final Logger logger = Logger.getLogger(Log4jConfigurator.class);
private final Path log4jConfigPath;
public Log4jConfigurator(String log4jConfigFile) {
this.log4jConfigPath = Paths.get(log4jConfigFile).toAbsolutePath();
}
#Override
public void run() {
try {
WatchService watcher = log4jConfigPath.getParent().getFileSystem().newWatchService();
log4jConfigPath.getParent().register(watcher, StandardWatchEventKinds.ENTRY_MODIFY);
while (!Thread.currentThread().isInterrupted()) {
WatchKey key = watcher.take();
for (WatchEvent<?> event : key.pollEvents()) {
if (event.kind() == StandardWatchEventKinds.ENTRY_MODIFY &&
log4jConfigPath.getFileName().toString().equals(event.context().toString())) {
logger.info("Reloading log4j configuration from file: " + log4jConfigPath);
PropertyConfigurator.configure(log4jConfigPath.toString());
}
}
key.reset();
}
} catch (InterruptedException e) {
logger.info("Log4j configuration monitoring thread interrupted.");
} catch (Exception e) {
logger.error("Error while monitoring log4j configuration file", e);
}
}
}
It works perfectly !
BUT, two problems :
1-
I used the same file that Jboss used (server.log), it seems to work but is this ok to write log from jboss and my own log4j in the same file ?
2-
All the log from this are messed up by log4j I presume, and so I had twice informations :
2023-01-25 17:24:44,493 INFO [STDOUT] [ INFO] com.myproject.someBusiness:938 - getOrder
2023-01-25 17:24:44,546 INFO [STDOUT] [ INFO] com.myproject.someBusiness:3138 - prices are refreshed
I already delete the date in log4j xml configuration file to not having twice the log date.
But for the rest (INFO...), it's all contained in the %m variable, so I can't do anything.
Why jboss add it's own prefix ?

Seems to work with this solution :
I put my log4j.properties into /opt/jboss/server/myserverinstance/conf/ directory.
I ask to Jboss to check this log4j.properties file instead of the old jboss-log4j.xml.
In jboss-service.xml :
<!-- ==================================================================== -->
<!-- Log4j Initialization -->
<!-- ==================================================================== -->
<mbean code="org.jboss.logging.Log4jService"
name="jboss.system:type=Log4jService,service=Logging"
xmbean-dd="resource:xmdesc/Log4jService-xmbean.xml">
<attribute name="ConfigurationURL">resource:log4j.properties</attribute>
<attribute name="Log4jQuietMode">true</attribute>
<attribute name="RefreshPeriod">10</attribute>
</mbean>
Then, I let my app check also this same properties file, no change made here.
I put this in my log4.properties file :
#Define root logger options
log4j.rootLogger=INFO, server
log4j.appender.status=org.apache.log4j.DailyRollingFileAppender
log4j.appender.status.File=${jboss.server.log.dir}/status.log
log4j.appender.status.DatePattern='.'yyyy-MM-dd
log4j.appender.status.layout=org.apache.log4j.PatternLayout
log4j.appender.status.layout.ConversionPattern=%d %-5p [%c] %m%n
log4j.appender.server=org.apache.log4j.DailyRollingFileAppender
log4j.appender.server.File=${jboss.server.log.dir}/server.log
log4j.appender.server.DatePattern='.'yyyy-MM-dd
log4j.appender.server.layout=org.apache.log4j.PatternLayout
log4j.appender.server.layout.ConversionPattern=%d %-5p [%c] %m%n
And that's it, it works great,I have both server messages and my app messages, without weird duplicate date, log level or anything.

Related

Issue while configuration WowzaStreamingEngine LoadBalancer_4.0

I got error with loadbalancer_4.0 plugin added in wowzasteamingengine:
can any one suggest me what was wrong and help me to solve out this issue.
i got this error---->
2015-07-27 11:22:22 IST comment server ERROR 500 - Encrypter:Decrypt() Error decrypting message: '<html><head><title>Wowza Streaming Engine 4 Trial Edition (Expires: Dec 09, 2015) 4.2.0 build15089</title></head><body>Wowza Streaming Engine 4 Trial Edition (Expires: Dec 09, 2015) 4.2.0 build15089</body></html>, : java.lang.NullPointerException|at com.wowza.wms.plugin.loadbalancer.encoders.Thor.decrypt(Thor.java:74)|at com.wowza.wms.plugin.loadbalancer.encoders.Encrypter.decrypt(Encrypter.java:106)|at com.wowza.wms.plugin.loadbalancer.general.XMLParser.xmlParse(XMLParser.java:55)|at com.wowza.wms.plugin.loadbalancer.general.URLHandler.clientConnectionURL(URLHandler.java:73)|at com.wowza.wms.plugin.loadbalancer.monitors.LoadBalanceBandwidthMonitorClient.run(LoadBalanceBandwidthMonitorClient.java:144)|
my server.xml -------->
<?xml version="1.0" encoding="UTF-8"?>
<Root version="2">
<Server>
<Name>Wowza Streaming Engine</Name>
<Description>Wowza Streaming Engine is robust, customizable, and scalable server software that powers reliable streaming of high-quality video and audio to any device, anywhere.</Description>
<RESTInterface>
<Enable>true</Enable>
<IPAddress>*</IPAddress>
<Port>8087</Port>
<!-- none, basic, digest-->
<AuthenticationMethod>digest</AuthenticationMethod>
<DiagnosticURLEnable>true</DiagnosticURLEnable>
<SSLConfig>
<Enable>false</Enable>
<KeyStorePath></KeyStorePath>
<KeyStorePassword></KeyStorePassword>
<KeyStoreType>JKS</KeyStoreType>
<SSLProtocol>TLS</SSLProtocol>
<Algorithm>SunX509</Algorithm>
<CipherSuites></CipherSuites>
<Protocols></Protocols>
</SSLConfig>
<IPWhiteList>127.0.0.1</IPWhiteList>
<IPBlackList></IPBlackList>
<EnableXMLFile>false</EnableXMLFile>
<DocumentationServerEnable>false</DocumentationServerEnable>
<DocumentationServerPort>8089</DocumentationServerPort>
<!-- none, basic, digest-->
<DocumentationServerAuthenticationMethod>digest</DocumentationServerAuthenticationMethod>
<Properties>
</Properties>
</RESTInterface>
<CommandInterface>
<HostPort>
<ProcessorCount>${com.wowza.wms.TuningAuto}</ProcessorCount>
<IpAddress>*</IpAddress>
<Port>8083</Port>
</HostPort>
</CommandInterface>
<AdminInterface>
<!-- Objects exposed through JMX interface: Server, VHost, VHostItem, Application, ApplicationInstance, MediaCaster, Module, Client, MediaStream, SharedObject, Acceptor, IdleWorker -->
<ObjectList>Server,VHost,VHostItem,Application,ApplicationInstance,MediaCaster,Module,IdleWorker</ObjectList>
</AdminInterface>
<Stats>
<Enable>true</Enable>
</Stats>
<!-- JMXUrl: service:jmx:rmi://localhost:8084/jndi/rmi://localhost:8085/jmxrmi -->
<JMXRemoteConfiguration>
<Enable>false</Enable>
<IpAddress>localhost</IpAddress> <!-- set to localhost or internal ip address if behind NAT -->
<RMIServerHostName>localhost</RMIServerHostName> <!-- set to external ip address or domain name if behind NAT -->
<RMIConnectionPort>8084</RMIConnectionPort>
<RMIRegistryPort>8085</RMIRegistryPort>
<Authenticate>true</Authenticate>
<PasswordFile>${com.wowza.wms.ConfigHome}/conf/jmxremote.password</PasswordFile>
<AccessFile>${com.wowza.wms.ConfigHome}/conf/jmxremote.access</AccessFile>
<SSLSecure>false</SSLSecure>
</JMXRemoteConfiguration>
<UserAgents>Shockwave Flash|CFNetwork|MacNetwork/1.0 (Macintosh)</UserAgents>
<Streams>
<DefaultStreamPrefix>mp4</DefaultStreamPrefix>
</Streams>
<ServerListeners>
<ServerListener>
<BaseClass>com.wowza.wms.mediacache.impl.MediaCacheServerListener</BaseClass>
</ServerListener>
<ServerListener>
<BaseClass>com.wowza.wms.plugin.loadbalancer.general.LoadBalancerServer</BaseClass>
</ServerListener>
<!--
<ServerListener>
<BaseClass>com.wowza.wms.plugin.loadbalancer.ServerListenerLoadBalancerListener</BaseClass>
</ServerListener>
-->
<!--
<ServerListener>
<BaseClass>com.wowza.wms.plugin.loadbalancer.ServerListenerLoadBalancerSender</BaseClass>
</ServerListener>
-->
</ServerListeners>
<VHostListeners>
<!--
<VHostListener>
<BaseClass></BaseClass>
</VHostListener>
-->
</VHostListeners>
<HandlerThreadPool>
<PoolSize>${com.wowza.wms.TuningAuto}</PoolSize>
</HandlerThreadPool>
<TransportThreadPool>
<PoolSize>${com.wowza.wms.TuningAuto}</PoolSize>
</TransportThreadPool>
<RTP>
<DatagramStartingPort>6970</DatagramStartingPort>
<DatagramPortSharing>false</DatagramPortSharing>
</RTP>
<Manager>
<!-- Properties defined are used by the Manager -->
<Properties>
</Properties>
</Manager>
<!-- Properties defined here will be added to the IServer.getProperties() collection -->
<Properties>
<Property>
<Name>loadbalanceType</Name>
<Value>Server,Client</Value>
<Type>String</Type>
</Property>
<Property>
<Name>loadbalanceKey</Name>
<Value>123456789012345</Value>
<Type>String</Type>
</Property>
<Property>
<Name>loadbalanceServerIP</Name>
<Value>192.168.2.91</Value>
<Type>String</Type>
</Property>
<Property>
<Name>loadbalanceServerPort</Name>
<Value>1935</Value>
<Type>String</Type>
</Property>
<Property>
<Name>loadbalanceDecisionOrder</Name>
<Value>Bandwidth,Connection</Value>
<Type>String</Type>
</Property>
<Property>
<Name>loadbalanceIgnoreClients</Name>
<Value>FMLE</Value>
<Type>String</Type>
</Property>
<Property>
<Name>loadbalanceBandwidthEnable</Name>
<Value>On</Value>
<Type>String</Type>
</Property>
<Property>
<Name>loadbalanceBandwidthLimit</Name>
<Value>50000</Value>
<Type>String</Type>
</Property>
<Property>
<Name>loadbalanceConnectionEnable</Name>
<Value>On</Value>
<Type>String</Type>
</Property>
<Property>
<Name>loadbalanceConnectionLimit</Name>
<Value>100</Value>
<Type>String</Type>
</Property>
</Properties>
</Server>
</Root>
my vhost.xml ------>
<?xml version="1.0" encoding="UTF-8"?>
<Root version="2">
<VHost>
<Description></Description>
<HostPortList>
<HostPort>
<Name>Default Streaming</Name>
<Type>Streaming</Type>
<ProcessorCount>${com.wowza.wms.TuningAuto}</ProcessorCount>
<IpAddress>*</IpAddress>
<!-- Separate multiple ports with commas -->
<!-- 80: HTTP, RTMPT -->
<!-- 554: RTSP -->
<Port>1935</Port>
<HTTPIdent2Response></HTTPIdent2Response>
<SocketConfiguration>
<ReuseAddress>true</ReuseAddress>
<!-- suggested settings for video on demand applications -->
<ReceiveBufferSize>65000</ReceiveBufferSize>
<ReadBufferSize>65000</ReadBufferSize>
<SendBufferSize>65000</SendBufferSize>
<!-- suggest settings for low latency chat and video recording applications
<ReceiveBufferSize>32000</ReceiveBufferSize>
<ReadBufferSize>32000</ReadBufferSize>
<SendBufferSize>32000</SendBufferSize>
-->
<KeepAlive>true</KeepAlive>
<!-- <TrafficClass>0</TrafficClass> -->
<!-- <OobInline>false</OobInline> -->
<!-- <SoLingerTime>-1</SoLingerTime> -->
<!-- <TcpNoDelay>false</TcpNoDelay> -->
<AcceptorBackLog>100</AcceptorBackLog>
</SocketConfiguration>
<HTTPStreamerAdapterIDs>cupertinostreaming,smoothstreaming,sanjosestreaming,dvrchunkstreaming,mpegdashstreaming</HTTPStreamerAdapterIDs>
<HTTPProviders>
<HTTPProvider>
<BaseClass>com.wowza.wms.http.HTTPCrossdomain</BaseClass>
<RequestFilters>*crossdomain.xml</RequestFilters>
<AuthenticationMethod>none</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.http.HTTPClientAccessPolicy</BaseClass>
<RequestFilters>*clientaccesspolicy.xml</RequestFilters>
<AuthenticationMethod>none</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.http.HTTPProviderMediaList</BaseClass>
<RequestFilters>*jwplayer.rss|*jwplayer.smil|*medialist.smil|*manifest-rtmp.f4m</RequestFilters>
<AuthenticationMethod>none</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.timedtext.http.HTTPProviderCaptionFile</BaseClass>
<RequestFilters>*.ttml|*.srt|*.scc|*.vtt</RequestFilters>
<AuthenticationMethod>none</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.http.HTTPServerVersion</BaseClass>
<RequestFilters>*</RequestFilters>
<AuthenticationMethod>none</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.plugin.loadbalancer.http.LoadBalancerPublicInterface</BaseClass>
<RequestFilters>redirect*</RequestFilters>
<AuthenticationMethod>none</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.plugin.loadbalancer.http.LoadBalancerInterface</BaseClass>
<RequestFilters>*loadbalancerInterface</RequestFilters>
<AuthenticationMethod>none</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.plugin.loadbalancer.http.LoadBalancerInformation</BaseClass>
<RequestFilters>*loadbalancerInfo</RequestFilters>
<AuthenticationMethod>admin-digest</AuthenticationMethod>
</HTTPProvider>
</HTTPProviders>
</HostPort>
<!-- 443 with SSL -->
<!--
<HostPort>
<Name>Default SSL Streaming</Name>
<Type>Streaming</Type>
<ProcessorCount>${com.wowza.wms.TuningAuto}</ProcessorCount>
<IpAddress>*</IpAddress>
<Port>443</Port>
<HTTPIdent2Response></HTTPIdent2Response>
<SSLConfig>
<KeyStorePath>${com.wowza.wms.context.VHostConfigHome}/conf/keystore.jks</KeyStorePath>
<KeyStorePassword>[password]</KeyStorePassword>
<KeyStoreType>JKS</KeyStoreType>
<SSLProtocol>TLS</SSLProtocol>
<Algorithm>SunX509</Algorithm>
<CipherSuites></CipherSuites>
<Protocols></Protocols>
</SSLConfig>
<SocketConfiguration>
<ReuseAddress>true</ReuseAddress>
<ReceiveBufferSize>65000</ReceiveBufferSize>
<ReadBufferSize>65000</ReadBufferSize>
<SendBufferSize>65000</SendBufferSize>
<KeepAlive>true</KeepAlive>
<AcceptorBackLog>100</AcceptorBackLog>
</SocketConfiguration>
<HTTPStreamerAdapterIDs>cupertinostreaming,smoothstreaming,sanjosestreaming,dvrchunkstreaming,mpegdashstreaming</HTTPStreamerAdapterIDs>
<HTTPProviders>
<HTTPProvider>
<BaseClass>com.wowza.wms.http.HTTPCrossdomain</BaseClass>
<RequestFilters>*crossdomain.xml</RequestFilters>
<AuthenticationMethod>none</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.http.HTTPClientAccessPolicy</BaseClass>
<RequestFilters>*clientaccesspolicy.xml</RequestFilters>
<AuthenticationMethod>none</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.http.HTTPProviderMediaList</BaseClass>
<RequestFilters>*jwplayer.rss|*jwplayer.smil|*medialist.smil|*manifest-rtmp.f4m</RequestFilters>
<AuthenticationMethod>none</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.http.HTTPServerVersion</BaseClass>
<RequestFilters>*</RequestFilters>
<AuthenticationMethod>none</AuthenticationMethod>
</HTTPProvider>
</HTTPProviders>
</HostPort>
-->
<!-- Admin HostPort -->
<HostPort>
<Name>Default Admin</Name>
<Type>Admin</Type>
<ProcessorCount>${com.wowza.wms.TuningAuto}</ProcessorCount>
<IpAddress>*</IpAddress>
<Port>8086</Port>
<HTTPIdent2Response></HTTPIdent2Response>
<SocketConfiguration>
<ReuseAddress>true</ReuseAddress>
<ReceiveBufferSize>16000</ReceiveBufferSize>
<ReadBufferSize>16000</ReadBufferSize>
<SendBufferSize>16000</SendBufferSize>
<KeepAlive>true</KeepAlive>
<AcceptorBackLog>100</AcceptorBackLog>
</SocketConfiguration>
<HTTPStreamerAdapterIDs></HTTPStreamerAdapterIDs>
<HTTPProviders>
<HTTPProvider>
<BaseClass>com.wowza.wms.http.streammanager.HTTPStreamManager</BaseClass>
<RequestFilters>streammanager*</RequestFilters>
<AuthenticationMethod>admin-digest</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.http.HTTPServerInfoXML</BaseClass>
<RequestFilters>serverinfo*</RequestFilters>
<AuthenticationMethod>admin-digest</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.http.HTTPConnectionInfo</BaseClass>
<RequestFilters>connectioninfo*</RequestFilters>
<AuthenticationMethod>admin-digest</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.http.HTTPConnectionCountsXML</BaseClass>
<RequestFilters>connectioncounts*</RequestFilters>
<AuthenticationMethod>admin-digest</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.transcoder.httpprovider.HTTPTranscoderThumbnail</BaseClass>
<RequestFilters>transcoderthumbnail*</RequestFilters>
<AuthenticationMethod>admin-digest</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.http.HTTPProviderMediaList</BaseClass>
<RequestFilters>medialist*</RequestFilters>
<AuthenticationMethod>admin-digest</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.livestreamrecord.http.HTTPLiveStreamRecord</BaseClass>
<RequestFilters>livestreamrecord*</RequestFilters>
<AuthenticationMethod>admin-digest</AuthenticationMethod>
</HTTPProvider>
<HTTPProvider>
<BaseClass>com.wowza.wms.http.HTTPServerVersion</BaseClass>
<RequestFilters>*</RequestFilters>
<AuthenticationMethod>none</AuthenticationMethod>
</HTTPProvider>
</HTTPProviders>
</HostPort>
</HostPortList>
<HTTPStreamerAdapters>
<HTTPStreamerAdapter>
<ID>smoothstreaming</ID>
<Name>smoothstreaming</Name>
<Properties>
</Properties>
</HTTPStreamerAdapter>
<HTTPStreamerAdapter>
<ID>cupertinostreaming</ID>
<Name>cupertinostreaming</Name>
<Properties>
</Properties>
</HTTPStreamerAdapter>
<HTTPStreamerAdapter>
<ID>sanjosestreaming</ID>
<Name>sanjosestreaming</Name>
<Properties>
</Properties>
</HTTPStreamerAdapter>
<HTTPStreamerAdapter>
<ID>dvrchunkstreaming</ID>
<Name>dvrchunkstreaming</Name>
<Properties>
</Properties>
</HTTPStreamerAdapter>
<HTTPStreamerAdapter>
<ID>mpegdashstreaming</ID>
<Name>mpegdashstreaming</Name>
<Properties>
</Properties>
</HTTPStreamerAdapter>
<HTTPStreamerAdapter>
<ID>tsstreaming</ID>
<Name>tsstreaming</Name>
<Properties>
</Properties>
</HTTPStreamerAdapter>
<HTTPStreamerAdapter>
<ID>webmstreaming</ID>
<Name>webmstreaming</Name>
<Properties>
</Properties>
</HTTPStreamerAdapter>
</HTTPStreamerAdapters>
<!-- When set to zero, thread pool configuration is done in Server.xml -->
<HandlerThreadPool>
<PoolSize>0</PoolSize>
</HandlerThreadPool>
<TransportThreadPool>
<PoolSize>0</PoolSize>
</TransportThreadPool>
<IdleWorkers>
<WorkerCount>${com.wowza.wms.TuningAuto}</WorkerCount>
<CheckFrequency>50</CheckFrequency>
<MinimumWaitTime>5</MinimumWaitTime>
</IdleWorkers>
<NetConnections>
<ProcessorCount>${com.wowza.wms.TuningAuto}</ProcessorCount>
<IdleFrequency>250</IdleFrequency>
<SocketConfiguration>
<ReuseAddress>true</ReuseAddress>
<ReceiveBufferSize>65000</ReceiveBufferSize>
<ReadBufferSize>65000</ReadBufferSize>
<SendBufferSize>65000</SendBufferSize>
<KeepAlive>true</KeepAlive>
<!-- <TrafficClass>0</TrafficClass> -->
<!-- <OobInline>false</OobInline> -->
<!-- <SoLingerTime>-1</SoLingerTime> -->
<!-- <TcpNoDelay>false</TcpNoDelay> -->
<AcceptorBackLog>100</AcceptorBackLog>
</SocketConfiguration>
</NetConnections>
<MediaCasters>
<ProcessorCount>${com.wowza.wms.TuningAuto}</ProcessorCount>
<SocketConfiguration>
<ReuseAddress>true</ReuseAddress>
<ReceiveBufferSize>65000</ReceiveBufferSize>
<ReadBufferSize>65000</ReadBufferSize>
<SendBufferSize>65000</SendBufferSize>
<KeepAlive>true</KeepAlive>
<!-- <TrafficClass>0</TrafficClass> -->
<!-- <OobInline>false</OobInline> -->
<!-- <SoLingerTime>-1</SoLingerTime> -->
<!-- <TcpNoDelay>false</TcpNoDelay> -->
<ConnectionTimeout>10000</ConnectionTimeout>
</SocketConfiguration>
</MediaCasters>
<LiveStreamTranscoders>
<MaximumConcurrentTranscodes>0</MaximumConcurrentTranscodes>
</LiveStreamTranscoders>
<HTTPTunnel>
<KeepAliveTimeout>2000</KeepAliveTimeout>
</HTTPTunnel>
<Client>
<ClientTimeout>90000</ClientTimeout>
<IdleFrequency>250</IdleFrequency>
</Client>
<!-- RTP/Authentication/Methods defined in Authentication.xml. Default setup includes; none, basic, digest -->
<RTP>
<IdleFrequency>75</IdleFrequency>
<DatagramConfiguration>
<Incoming>
<ReuseAddress>true</ReuseAddress>
<ReceiveBufferSize>2048000</ReceiveBufferSize>
<SendBufferSize>65000</SendBufferSize>
<!-- <MulticastBindToAddress>true</MulticastBindToAddress> -->
<!-- <MulticastInterfaceAddress>192.168.1.22</MulticastInterfaceAddress> -->
<!-- <TrafficClass>0</TrafficClass> -->
<MulticastTimeout>50</MulticastTimeout>
<DatagramMaximumPacketSize>4096</DatagramMaximumPacketSize>
</Incoming>
<Outgoing>
<ReuseAddress>true</ReuseAddress>
<ReceiveBufferSize>65000</ReceiveBufferSize>
<SendBufferSize>256000</SendBufferSize>
<!-- <MulticastBindToAddress>true</MulticastBindToAddress> -->
<!-- <MulticastInterfaceAddress>192.168.1.22</MulticastInterfaceAddress> -->
<!-- <TrafficClass>0</TrafficClass> -->
<MulticastTimeout>50</MulticastTimeout>
<DatagramMaximumPacketSize>4096</DatagramMaximumPacketSize>
</Outgoing>
</DatagramConfiguration>
<UnicastIncoming>
<ProcessorCount>${com.wowza.wms.TuningAuto}</ProcessorCount>
</UnicastIncoming>
<UnicastOutgoing>
<ProcessorCount>${com.wowza.wms.TuningAuto}</ProcessorCount>
</UnicastOutgoing>
<MulticastIncoming>
<ProcessorCount>${com.wowza.wms.TuningAuto}</ProcessorCount>
</MulticastIncoming>
<MulticastOutgoing>
<ProcessorCount>${com.wowza.wms.TuningAuto}</ProcessorCount>
</MulticastOutgoing>
</RTP>
<Application>
<ApplicationTimeout>60000</ApplicationTimeout>
<PingTimeout>12000</PingTimeout>
<UnidentifiedSessionTimeout>30000</UnidentifiedSessionTimeout>
<ValidationFrequency>20000</ValidationFrequency>
<MaximumPendingWriteBytes>0</MaximumPendingWriteBytes>
<MaximumSetBufferTime>60000</MaximumSetBufferTime>
</Application>
<StartStartupStreams>true</StartStartupStreams>
<Manager>
<TestPlayer>
<IpAddress>${com.wowza.wms.HostPort.IpAddress}</IpAddress>
<Port>${com.wowza.wms.HostPort.FirstStreamingPort}</Port>
<SSLEnable>${com.wowza.wms.HostPort.SSLEnable}</SSLEnable>
</TestPlayer>
<!-- Properties defined are used by the Manager -->
<Properties>
</Properties>
</Manager>
<!-- Properties defined here will be added to the IVHost.getProperties() collection -->
<Properties>
</Properties>
</VHost>
</Root>
my redirect(Application.xml) it's a vod type ---->
<?xml version="1.0" encoding="UTF-8"?>
<Root version="1">
<Application>
<Name>redirect</Name>
<AppType>VOD</AppType>
<Description></Description>
<!-- Uncomment to set application level timeout values
<ApplicationTimeout>60000</ApplicationTimeout>
<PingTimeout>12000</PingTimeout>
<ValidationFrequency>8000</ValidationFrequency>
<MaximumPendingWriteBytes>0</MaximumPendingWriteBytes>
<MaximumSetBufferTime>60000</MaximumSetBufferTime>
<MaximumStorageDirDepth>25</MaximumStorageDirDepth>
-->
<Connections>
<AutoAccept>true</AutoAccept>
<AllowDomains></AllowDomains>
</Connections>
<!--
StorageDir path variables
${com.wowza.wms.AppHome} - Application home directory
${com.wowza.wms.ConfigHome} - Configuration home directory
${com.wowza.wms.context.VHost} - Virtual host name
${com.wowza.wms.context.VHostConfigHome} - Virtual host home directory
${com.wowza.wms.context.Application} - Application name
${com.wowza.wms.context.ApplicationInstance} - Application instance name
-->
<Streams>
<StreamType>default</StreamType>
<StorageDir>${com.wowza.wms.context.VHostConfigHome}/content</StorageDir>
<KeyDir>${com.wowza.wms.context.VHostConfigHome}/keys</KeyDir>
<!-- LiveStreamPacketizers (separate with commas): cupertinostreamingpacketizer, smoothstreamingpacketizer, sanjosestreamingpacketizer, mpegdashstreamingpacketizer, cupertinostreamingrepeater, smoothstreamingrepeater, sanjosestreamingrepeater, mpegdashstreamingrepeater, dvrstreamingpacketizer, dvrstreamingrepeater -->
<LiveStreamPacketizers></LiveStreamPacketizers>
<!-- Properties defined here will override any properties defined in conf/Streams.xml for any streams types loaded by this application -->
<Properties>
</Properties>
</Streams>
<Transcoder>
<!-- To turn on transcoder set to: transcoder -->
<LiveStreamTranscoder></LiveStreamTranscoder>
<!-- [templatename].xml or ${SourceStreamName}.xml -->
<Templates>${SourceStreamName}.xml,transrate.xml</Templates>
<ProfileDir>${com.wowza.wms.context.VHostConfigHome}/transcoder/profiles</ProfileDir>
<TemplateDir>${com.wowza.wms.context.VHostConfigHome}/transcoder/templates</TemplateDir>
<Properties>
</Properties>
</Transcoder>
<DVR>
<!-- As a single server or as an origin, use dvrstreamingpacketizer in LiveStreamPacketizers above -->
<!-- Or, in an origin-edge configuration, edges use dvrstreamingrepeater in LiveStreamPacketizers above -->
<!-- As an origin, also add dvrchunkstreaming to HTTPStreamers below -->
<!-- If this is a dvrstreamingrepeater, define Application/Repeater/OriginURL to point back to the origin -->
<!-- To turn on DVR recording set Recorders to dvrrecorder. This works with dvrstreamingpacketizer -->
<Recorders></Recorders>
<!-- As a single server or as an origin, set the Store to dvrfilestorage-->
<!-- edges should have this empty -->
<Store></Store>
<!-- Window Duration is length of live DVR window in seconds. 0 means the window is never trimmed. -->
<WindowDuration>0</WindowDuration>
<!-- Storage Directory is top level location where dvr is stored. e.g. c:/temp/dvr -->
<StorageDir>${com.wowza.wms.context.VHostConfigHome}/dvr</StorageDir>
<!-- valid ArchiveStrategy values are append, version, delete -->
<ArchiveStrategy>append</ArchiveStrategy>
<!-- Properties for DVR -->
<Properties>
</Properties>
</DVR>
<TimedText>
<!-- VOD caption providers (separate with commas): vodcaptionprovidermp4_3gpp, vodcaptionproviderttml, vodcaptionproviderwebvtt, vodcaptionprovidersrt, vodcaptionproviderscc -->
<VODTimedTextProviders>vodcaptionprovidermp4_3gpp</VODTimedTextProviders>
<!-- Properties for TimedText -->
<Properties>
</Properties>
</TimedText>
<!-- HTTPStreamers (separate with commas): cupertinostreaming, smoothstreaming, sanjosestreaming, mpegdashstreaming, dvrchunkstreaming -->
<HTTPStreamers>sanjosestreaming, cupertinostreaming, smoothstreaming, mpegdashstreaming</HTTPStreamers>
<MediaCache>
<MediaCacheSourceList></MediaCacheSourceList>
</MediaCache>
<SharedObjects>
<StorageDir>${com.wowza.wms.context.VHostConfigHome}/applications/${com.wowza.wms.context.Application}/sharedobjects/${com.wowza.wms.context.ApplicationInstance}</StorageDir>
</SharedObjects>
<Client>
<IdleFrequency>-1</IdleFrequency>
<Access>
<StreamReadAccess>*</StreamReadAccess>
<StreamWriteAccess></StreamWriteAccess>
<StreamAudioSampleAccess></StreamAudioSampleAccess>
<StreamVideoSampleAccess></StreamVideoSampleAccess>
<SharedObjectReadAccess>*</SharedObjectReadAccess>
<SharedObjectWriteAccess>*</SharedObjectWriteAccess>
</Access>
</Client>
<RTP>
<!-- RTP/Authentication/[type]Methods defined in Authentication.xml. Default setup includes; none, basic, digest -->
<Authentication>
<PublishMethod>block</PublishMethod>
<PlayMethod>none</PlayMethod>
</Authentication>
<!-- RTP/AVSyncMethod. Valid values are: senderreport, systemclock, rtptimecode -->
<AVSyncMethod>senderreport</AVSyncMethod>
<MaxRTCPWaitTime>12000</MaxRTCPWaitTime>
<IdleFrequency>75</IdleFrequency>
<RTSPSessionTimeout>90000</RTSPSessionTimeout>
<RTSPMaximumPendingWriteBytes>0</RTSPMaximumPendingWriteBytes>
<RTSPBindIpAddress></RTSPBindIpAddress>
<RTSPConnectionIpAddress>0.0.0.0</RTSPConnectionIpAddress>
<RTSPOriginIpAddress>127.0.0.1</RTSPOriginIpAddress>
<IncomingDatagramPortRanges>*</IncomingDatagramPortRanges>
<!-- Properties defined here will override any properties defined in conf/RTP.xml for any depacketizers loaded by this application -->
<Properties>
</Properties>
</RTP>
<MediaCaster>
<RTP>
<RTSP>
<!-- udp, interleave -->
<RTPTransportMode>interleave</RTPTransportMode>
</RTSP>
</RTP>
<StreamValidator>
<Enable>true</Enable>
<ResetNameGroups>true</ResetNameGroups>
<StreamStartTimeout>20000</StreamStartTimeout>
<StreamTimeout>12000</StreamTimeout>
<VideoStartTimeout>0</VideoStartTimeout>
<VideoTimeout>0</VideoTimeout>
<AudioStartTimeout>0</AudioStartTimeout>
<AudioTimeout>0</AudioTimeout>
<VideoTCToleranceEnable>false</VideoTCToleranceEnable>
<VideoTCPosTolerance>3000</VideoTCPosTolerance>
<VideoTCNegTolerance>-500</VideoTCNegTolerance>
<AudioTCToleranceEnable>false</AudioTCToleranceEnable>
<AudioTCPosTolerance>3000</AudioTCPosTolerance>
<AudioTCNegTolerance>-500</AudioTCNegTolerance>
<DataTCToleranceEnable>false</DataTCToleranceEnable>
<DataTCPosTolerance>3000</DataTCPosTolerance>
<DataTCNegTolerance>-500</DataTCNegTolerance>
<AVSyncToleranceEnable>false</AVSyncToleranceEnable>
<AVSyncTolerance>1500</AVSyncTolerance>
<DebugLog>false</DebugLog>
</StreamValidator>
<!-- Properties defined here will override any properties defined in conf/MediaCasters.xml for any MediaCasters loaded by this applications -->
<Properties>
</Properties>
</MediaCaster>
<MediaReader>
<!-- Properties defined here will override any properties defined in conf/MediaReaders.xml for any MediaReaders loaded by this applications -->
<Properties>
</Properties>
</MediaReader>
<MediaWriter>
<!-- Properties defined here will override any properties defined in conf/MediaWriter.xml for any MediaWriter loaded by this applications -->
<Properties>
</Properties>
</MediaWriter>
<LiveStreamPacketizer>
<!-- Properties defined here will override any properties defined in conf/LiveStreamPacketizers.xml for any LiveStreamPacketizers loaded by this applications -->
<Properties>
</Properties>
</LiveStreamPacketizer>
<HTTPStreamer>
<!-- Properties defined here will override any properties defined in conf/HTTPStreamers.xml for any HTTPStreamer loaded by this applications -->
<Properties>
</Properties>
</HTTPStreamer>
<Manager>
<!-- Properties defined are used by the Manager -->
<Properties>
</Properties>
</Manager>
<Repeater>
<OriginURL></OriginURL>
<QueryString><![CDATA[]]></QueryString>
</Repeater>
<StreamRecorder>
<Properties>
</Properties>
</StreamRecorder>
<Modules>
<Module>
<Name>base</Name>
<Description>Base</Description>
<Class>com.wowza.wms.module.ModuleCore</Class>
</Module>
<Module>
<Name>logging</Name>
<Description>Client Logging</Description>
<Class>com.wowza.wms.module.ModuleClientLogging</Class>
</Module>
<Module>
<Name>flvplayback</Name>
<Description>FLVPlayback</Description>
<Class>com.wowza.wms.module.ModuleFLVPlayback</Class>
</Module>
<Module>
<Name>Redirect</Name>
<Description>Redirect</Description>
<Class>com.wowza.wms.plugin.loadbalancer.redirect.ClientConnections</Class>
</Module>
</Modules>
<!-- Properties defined here will be added to the IApplication.getProperties() and IApplicationInstance.getProperties() collections -->
<Properties>
</Properties>
</Application>
</Root>
Please help me out to solve this issue
thanks in advance

log4j - how to log to seperate/different files

my application is runnig on jboss 7.3. Log4j configuration file looks
<log4j:configuration debug="true"
xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="fileAppender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="encoding" value="UTF-8" />
<param name="append" value="true" />
<param name="file" value="${jboss.server.log.dir}/mainWS.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %d{yyyy-MM-dd HH:mm:ss:SSS} %m rid%X{rid}%n" />
</layout>
</appender>
<appender name="File1" class="org.apache.log4j.DailyRollingFileAppender">
<param name="encoding" value="UTF-8" />
<param name="append" value="true" />
<param name="file" value="${jboss.server.log.dir}/file1.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %d{yyyy-MM-dd HH:mm:ss:SSS} %m rid%X{rid}%n" />
</layout>
</appender>
<appender name="File2" class="org.apache.log4j.DailyRollingFileAppender">
<param name="encoding" value="UTF-8" />
<param name="append" value="true" />
<param name="file" value="${jboss.server.log.dir}/file2.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %d{yyyy-MM-dd HH:mm:ss:SSS} %m rid%X{rid}%n" />
</layout>
</appender>
<appender name="opTimeFile" class="org.apache.log4j.DailyRollingFileAppender">
<param name="encoding" value="UTF-8" />
<param name="append" value="true" />
<param name="file" value="${jboss.server.log.dir}/opTime.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %d{yyyy-MM-dd HH:mm:ss:SSS} %m rid%X{rid}%n" />
</layout>
</appender>
<logger name="debugLogger" additivity="false">
<level value="DEBUG" />
<appender-ref ref="fileAppender" />
</logger>
<logger name="Logger1" additivity="false">
<level value="DEBUG" />
<appender-ref ref="File1" />
</logger>
<logger name="Logger2" additivity="false">
<level value="DEBUG" />
<appender-ref ref="File2" />
</logger>
<logger name="opTimeLogger" additivity="false">
<level value="DEBUG" />
<appender-ref ref="opTimeFile" />
</logger>
<root>
<priority value="OFF" />
</root>
files are created in log directory, but loggin only performed in mainWS.log
I've tried
private static final Logger log = Logger.getLogger("debugLogger");
private static final Logger vLog = Logger.getLogger("Logger1");
private static final Logger eLog = Logger.getLogger("Logger2");
private static final Logger tLog = Logger.getLogger("opTimeLogger");
for (Enumeration loggers= LogManager.getCurrentLoggers(); loggers.hasMoreElements(); ) {
Logger logger = (Logger) loggers.nextElement();
log.debug("logger - " + logger.getName());
vLog.debug("vLogger - " + logger.getName());
eLog.debug("eLogger - " + logger.getName());
tLog.debug("tLogger - " + logger.getName());
for (Enumeration appenders=logger.getAllAppenders(); appenders.hasMoreElements(); ) {
Appender appender = (Appender) appenders.nextElement();
log.debug("appender - " + appender.getName());
vLog.debug("vAppender - " + appender.getName());
eLog.debug("eAppender - " + appender.getName());
tLog.debug("tAppender - " + appender.getName());
}
}
but result is only in mainWS.log file
DEBUG 2014-11-13 10:29:03:125 logger - rid
DEBUG 2014-11-13 10:29:03:138 logger - opTimeLogger rid
DEBUG 2014-11-13 10:29:03:138 logger - Logger1 rid
DEBUG 2014-11-13 10:29:03:138 logger - debugLogger rid
DEBUG 2014-11-13 10:29:03:138 appender - fileAppender rid
DEBUG 2014-11-13 10:29:03:139 logger - Logger2 rid
it seems that only debugLogger has an appender.
Any ideas?
I guess there was a conflict between log4j and the default logging implementation of the application server. I had to exclude the module from your deployment.
I added a WEB-INF/jboss-deployment-structure.xml file
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</deployment>
I had to include log4j libraries in my application classpath as well.
now it works
My first guess is that log4j reads a different config file than you expect. Check the debug output of log4j when it starts and especially the paths in there.

GWT remote logging going to System.out instead of log file

I have setup gwt remote logging based on the gwt documentation, however my logs are going to System.out instead of being written to a log file.
My gwt module looks like:
<module rename-to='ezdappserver'>
<inherits name="com.google.gwt.logging.Logging"/>
<set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED" />
<set-property name="gwt.logging.logLevel" value="FINEST"/>
<set-property name="gwt.logging.enabled" value="TRUE"/>
<set-property name="gwt.logging.consoleHandler" value="ENABLED" />
<set-property name="gwt.logging.popupHandler" value="DISABLED" />
</module>
My servlet definition is setup like:
<servlet>
<servlet-name>remoteLogging</servlet-name>
<servlet-class>com.google.gwt.logging.server.RemoteLoggingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>remoteLogging</servlet-name>
<url-pattern>/ezdappserver/remote_logging</url-pattern>
</servlet-mapping>
When an error is logged I see output in my console like so:
Mar 26, 2014 2:10:36 PM com.google.gwt.logging.server.RemoteLoggingServiceUtil logOnServer
SEVERE: Exception caught: (NotFoundError)
....Rest of error....
I was expecting this output to be written to a log file somewhere in my war. Also, I would really like to be able to specify where this file is located, however I haven't been able to find any documentation on that either.
Any help would be much appreciated.
NOTE: I am not running this through dev mode, this is with compiled code.
Thanks!
Try below options also in gwt.xml based on your requirement:
<!-- This handler sends log messages to the server, where they will be logged using the server side logging mechanism. -->
<set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED" />
<!-- Logs by calling method GWT.log. These messages can only be seen in Development Mode in the DevMode window. -->
<set-property name="gwt.logging.developmentModeHandler" value="ENABLED" />
<!-- These messages can only be seen in Development Mode in the DevMode window. -->
<set-property name="gwt.logging.systemHandler" value="ENABLED" />
<!-- Logs to the popup which resides in the upper left hand corner of application when this handler is enabled. -->
<set-property name="gwt.logging.popupHandler" value="DISABLED" />
<!-- Logs to the javascript console, which is used by Firebug Lite (for IE), Safari and Chrome. -->
<set-property name="gwt.logging.consoleHandler" value="DISABLED"/>
<!-- Logs to the firebug console. -->
<set-property name="gwt.logging.firebugHandler" value="DISABLED" />
If above configuration are still not working for you then try below code along with above configuration.
Add log4j.xml file to define the log file location with log level
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="DT=> %d [%.4t] %-5p %c{1} - %m%n" />
</layout>
</appender>
<appender name="SERVER_FILE_LOG" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="${jboss.server.log.dir}/logs/DataTools_Server.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="5MB" />
<param name="MaxBackupIndex" value="10" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%.4t] %-5p [%c] %m%n" />
</layout>
</appender>
<appender name="CLIENT_FILE_LOG" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="${jboss.server.log.dir}/logs/DataTools_Client.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="5MB" />
<param name="MaxBackupIndex" value="10" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%.4t] %-5p %m%n" />
</layout>
</appender>
<category name="com.x.y.server">
<priority value="DEBUG" />
<appender-ref ref="SERVER_FILE_LOG" />
<appender-ref ref="STDOUT" />
</category>
<category name="gwtRemoteLogging">
<priority value="ERROR" />
<appender-ref ref="CLIENT_FILE_LOG" />
</category>
<root>
<priority value ="ERROR" />
<appender-ref ref="SERVER_FILE_LOG" />
</root>
</log4j:configuration>
Define you own logging servlet by implementing RemoteLoggingService
import java.util.logging.Level;
import java.util.logging.LogRecord;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import com.google.gwt.logging.server.StackTraceDeobfuscator;
import com.google.gwt.logging.shared.RemoteLoggingService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import org.apache.log4j.Logger;
/**
* The Class GwtRemoteLogging.
*/
#SuppressWarnings("serial")
public class GwtRemoteLogging extends RemoteServiceServlet implements RemoteLoggingService {
/** The Constant logger. */
private StackTraceDeobfuscator deobfuscator = null;
private final static Logger logger = Logger.getLogger("gwtRemoteLogging");
#Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
/**
* Logs a Log Record which has been serialized using GWT RPC on the server.
*
* #return either an error message, or null if logging is successful.
*/
public final String logOnServer(LogRecord lr) {
try {
if (lr.getLevel().equals(Level.SEVERE)) {
logger.error(lr.getMessage(),lr.getThrown());
} else if (lr.getLevel().equals(Level.INFO)) {
logger.info(lr.getMessage(),lr.getThrown());
} else if (lr.getLevel().equals(Level.WARNING)) {
logger.warn(lr.getMessage(),lr.getThrown());
} else if (lr.getLevel().equals(Level.FINE)) {
logger.debug(lr.getMessage(),lr.getThrown());
} else {
logger.trace(lr.getMessage(),lr.getThrown());
}
} catch (Exception e) {
logger.error("Remote logging failed", e);
return "Remote logging failed, check stack trace for details.";
}
return null;
}
/**
* By default, this service does not do any deobfuscation. In order to do server side
* deobfuscation, you must copy the symbolMaps files to a directory visible to the server and
* set the directory using this method.
*
* #param symbolMapsDir
*/
public void setSymbolMapsDirectory(String symbolMapsDir) {
if (deobfuscator == null) {
deobfuscator = new StackTraceDeobfuscator(symbolMapsDir);
} else {
deobfuscator.setSymbolMapsDirectory(symbolMapsDir);
}
}
}
web.xml
<servlet>
<servlet-name>remoteLogServlet</servlet-name>
<servlet-class>com.x.y.server.servlet.GwtRemoteLogging</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>remoteLogServlet</servlet-name>
<url-pattern>/ezdappserver/remote_logging</url-pattern>
</servlet-mapping>
The RemoteServiceServlet uses java.util.logging to log, and by default it logs to the console (System.err, not System.out BTW).
If you want to log to a file, then you have to configure java.util.logging; either editing your global lib/logging.properties (not recommended), using your own config file that you pass to the JVM using the java.util.logging.config.file system property, or programmatically.
Depending on your servlet container, it can be configured by different means. For instance, Tomcat will read a logging.properties file in your WEB-INF/classes: http://tomcat.apache.org/tomcat-7.0-doc/logging.html#Using_java.util.logging_(default)

struts2-rest plugin..making both struts actions + rest actions work together but. giving java.lang.reflect.InvocationTargetException

I am converting my existing struts 2 application to serve through some rest based services also.
I have used two plugins, struts2-rest plugin and struts-convention plugin,
Along with these I have also used asm.jar because above was giving a class not found exception which was there in asm jar.
I want to have both the functionalities as ..my normal struts action mappings should also work along with rest urls.
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- Overwrite Convention -->
<constant name="struts.convention.action.mapAllMatches" value="true"/>
<constant name="struts.convention.action.suffix" value="Controller"/>
<constant name="struts.convention.default.parent.package" value="rest-default"/>
<constant name="struts.mapper.class"value="org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper" />
<constant name="struts.mapper.prefixMapping" value="/rest:rest,:struts" />
<package name="userlogin" extends="struts-default" namespace="/">
<action>
......
</action>
</package>
<package name="secureAction" extends="struts-default,json-default"
namespace="/secure">
<interceptors>
...............
</interceptors>
<default-interceptor-ref name="secureStack" />
<global-results>
.............
</global-results>
<global-exception-mappings>
..............
</global-exception-mappings>
</package>
<include file=".....xml" />
</struts>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
.........
<display-name>strutsTest</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
....
</welcome-file-list>
<servlet>
<description></description>
<display-name>Logger</display-name>
<servlet-name>Logger</servlet-name>
<servlet-class>...........</servlet-class>
<init-param>
<param-name>log4j-properties-location</param-name>
<param-value>WEB-INF/log4j.properties</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Logger</servlet-name>
<url-pattern>/Logger</url-pattern>
</servlet-mapping>
I m not able to find any error..
what i see on screen when i run either struts action based mapping or rest url ..is :
Struts has detected an unhandled exception:
Messages:
com.thoughtworks.xstream.XStream
com/thoughtworks/xstream/XStream
java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
File: org/apache/catalina/loader/WebappClassLoader.java
Line number: 1,516
ive solved the problem with customMapper..
this is my custom mapper class....
package org.apache.struts2.rest.example;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.dispatcher.mapper.ActionMapper;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
import org.apache.struts2.dispatcher.mapper.DefaultActionMapper;
import com.opensymphony.xwork2.config.ConfigurationManager;
public class CustomActionMapper extends DefaultActionMapper {
public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager) {
return getActionMapper(request, configManager).getMapping(request, configManager);
}
private ActionMapper getActionMapper(HttpServletRequest request, ConfigurationManager configManager) {
ActionMapping actionMapping = new ActionMapping();
parseNameAndNamespace(request.getRequestURI(), actionMapping, configManager);
if (!(actionMapping.getNamespace()).contains("/rest")) {
return container.getInstance(ActionMapper.class, "struts");
}
else
{
return container.getInstance(ActionMapper.class, "rest");
}
}
...........................................
my struts.xml is as follows......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- Overwrite Convention -->
<bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="myActionMapper" class="org.apache.struts2.rest.example.CustomActionMapper" />
<constant name="struts.mapper.class" value="myActionMapper" />
<constant name="struts.convention.action.suffix" value="Controller"/>
<constant name="struts.convention.action.mapAllMatches" value="true"/>
<constant name="struts.convention.default.parent.package" value="rest-default"/>
<constant name="struts.convention.package.locators" value="example"/>
<constant name="struts.action.extension" value="xhtml,,xml,json,action"/>
<!-- overwrite action complete -->
<!-- normal struts actions -->
<package name="userlogin" extends="struts-default" namespace="/">
<action name="*">
<result name="error">/view/error/error.jsp</result>
</action>
..................
</package>
<include file="..........xml" />
<include file=".............xml" />
<!-- normal stryts actions complete -->
</struts>
these are the libraries im using ..
- asm-3.1.jar
- asm-commons-3.1.jar
- commons-beanutils-1.7.0.jar
- commons-collections-3.1.jar
- commons-fileupload-1.2.2.jar
- commons-io-2.0.1.jar
- commons-lang-2.5.jar
- commons-logging-1.1.1.jar
- commons-logging-api-1.1.jar
- ezmorph-1.0.3.jar
- freemarker-2.3.16.jar
- javassist-3.11.0.GA.jar
- json-lib-2.1-jdk15.jar
- log4j-1.2.8.jar
- ognl-3.0.1.jar
- struts2-convention-plugin-2.2.3.jar
- struts2-core-2.2.3.jar
- struts2-json-plugin-2.2.3.jar
- struts2-rest-plugin-2.2.3.jar
- xpp3_min-1.1.3.4.O.jar
- xstream-1.2.2.jar
- xwork-core-2.2.3.jar
make sure you use compatible library versions....

Append message to JBoss Console using jboss-log4j.xml

I'm unable to append messages from my application to the JBoss console. The following are the changes that I made to the jboss-log4j.xml configuration file:
<category name="com.tricubes">
<priority value="INFO"/>
<appender-ref ref="CONSOLE"/>
</category>
Here is my code:
public class OneToOneValidation2 {
private static final Logger logger = Logger.getLogger("com.tricubes");
public boolean validate(byte[] fpImage, byte[] fpTemplate, String desc, String ticket) {
...
logger.info("BES INFO: SOCKET MSG SENT " + intToByteArray(x));
...
return b;
}
}
What am I missing?
TIA!
Edited:
The console appender. Also is the default appender used by JBoss.
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="Target" value="System.out"/>
<param name="Threshold" value="INFO"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
</layout>
I have tried with both org.jboss.logging.Logger and org.apache.log4j.Logger;
Category is deprecated (use Logger), and Priority is not recommended (use Level). So your config block should be:
<logger name="com.tricubes">
<level value="INFO"/>
<appender-ref ref="CONSOLE"/>
</logger>
Also, what is your CONSOLE appender defined as? If its not pointing at the JBoss console, it wont log there.