I am trying to add wire-tap to intercept the channel but it is not using my logback configuration but instead it uses org.apache.commons.logging.impl.Jdk14Logger.
How do tell LoggingHandler.messageLogger to use lmy logback configuration?
<int:channel id="testChannel">
<int:interceptors>
<int:wire-tap channel="loggerChannel"/>
</int:interceptors>
</int:channel>
<int:logging-channel-adapter id="loggerChannel" level="DEBUG"/>
My logback has following configurayion defined
<logger name="org.springframework" level="DEBUG"/>
<logger name="org.springframework.integration" level="DEBUG"/>
<logger name="org.springframework.integration.handler.LoggingHandler" level="DEBUG"/>
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
<appender-ref ref="ROLLING"/>
</root>
For historical reasons, Spring uses commons-logging internally; you can wire in logback using slf4j.
See the note in the Spring Reference.
Here's another howto.
Essentially you need to exclude commons-logging from spring deps and add jcl-over-slf4j.
Related
Could you tell me how to log the SOAP Message send/received of int-ws:outbound-gateway ?
I have tried
<int-ws:outbound-gateway id="ais-outbound-gateway"
request-channel="aisRequestChannel" reply-channel="aisResponseChannel"
uri="http://localhost:8080/services/ONESHOT"
marshaller="aisMarshaller" unmarshaller="aisMarshaller" />
<int:channel id="aisRequestChannel">
<int:interceptors>
<int:wire-tap channel="logChannel"/>
</int:interceptors>
</int:channel>
<int:channel id="aisResponseChannel">
<int:interceptors>
<int:wire-tap channel="logChannel"/>
</int:interceptors>
</int:channel>
<int:logging-channel-adapter expression="payload" id="logChannel" level="DEBUG" />
But the payload is just java object, not SOAP message.
Best regards,
The <int-ws:outbound-gateway> supports interceptor injection:
<xsd:documentation>
Reference to the bean definition of a ClientInterceptor.
</xsd:documentation>
So, you should implement your own LoggingClientInterceptor.
The logging ideas you can borrow from the existing PayloadLoggingInterceptor.
We are hosting sitecore 8.1 in azure web apps. We log the errors on to App Dynamic where the application ticket will auto-created for each error.
The problem is that 90% of errors are raised by builtin sitecore piepelines e.g. GeoIP service not setup, session end not setup (due to MongoDB) etc.
Is it possible to identify and filter out the errors raised by built in pipelines and events in Sitecore?
Thanks.
Sitecore uses Log4Net as a framework for its logging. I haven't done it myself but I'd bet you can use standard L4N techniques to filter messages. It's probably just a config tweak or two.
You might prefer instead to spend the same time and research effort correcting the issues in Sitecore? Most services can be disabled if you aren't using them (and if they are raising errors then they aren't working anyway, right). Remove items from pipelines, disable tracking.
This way not only will you see fewer errors in your logs, your site will go faster as well!
If you only want the log files to log errors in the system, you need to set your logging level to ERROR in the log4net setup.
<log4net>
<!-- The appenders will go here -->
<root>
<priority value="ERROR" />
<appender-ref ref="LogFileAppender" />
</root>
<logger name="Sitecore.Diagnostics.WebDAV" additivity="false">
<level value="ERROR" />
<appender-ref ref="WebDAVLogFileAppender" />
</logger>
<logger name="Sitecore.Diagnostics.Search" additivity="false">
<level value="ERROR" />
<appender-ref ref="SearchLogFileAppender" />
</logger>
<logger name="Sitecore.Diagnostics.Crawling" additivity="false">
<level value="ERROR" />
<appender-ref ref="CrawlingLogFileAppender" />
</logger>
<logger name="Sitecore.Diagnostics.Publishing" additivity="false">
<level value="ERROR" />
<appender-ref ref="PublishingLogFileAppender" />
</logger>
<logger name="Sitecore.FXM.Diagnostics" additivity="false">
<level value="ERROR" />
<appender-ref ref="FxmLogFileAppender" />
</logger>
</log4net>
If you want to disable a particular log file, set the level value to NONE.
Bare in mind tho, setting the level to ERROR will stop all info and warning entries from being logged, so you may miss important entries for debugging issues.
You can just use the default Log4net and write to the same log file that sitecore uses, you dont even need to modify the webconfig to do this. It will be something like this:
Sitecore.Diagnostics.Log.Error(
Once you type this you'll see the different options you have to construct the log error. For identifying the type and where it came from you can check the exception type and stack and go from there, in this case you should create a global exception handling class and pull all the exception in there and run them through your identification/categorization methods!
Make sure you reference this 2:
using log4net;
using Sitecore.Diagnostics;
In mule CE version 3.3.0, I have a mule project, and the URL for calling it is http://localhost:8086/mule?msg=Hello-World!!!.
Every time that I call it, in a log file in mule server that it has as a default some lines added as a log.
Now I want to change type of logs in mule? I want to instead the file that mule create it for logs, as a default mule create a table into Database and save important info into it.
Actually I want to have a table log for my projects, and in this table I want to have customers' information such as IP and ...
Is it possible?
How can I do it?
You can use Log4j database appender to insert Mule ESB logs into database. Below code snippet is used to do the same.
<appender name="DB" class="org.apache.log4j.jdbc.JDBCAppender">
<param name="url" value="jdbc:mysql://localhost/DBNAME"/>
<param name="driver" value="com.mysql.jdbc.Driver"/>
<param name="user" value="user_id"/>
<param name="password" value="password"/>
<param name="sql" value="INSERT INTO LOGS VALUES('%level','%message','%X{muleMessage}','%X{payload}')"/>
<layout class="org.apache.log4j.PatternLayout">
</layout>
</appender>
<logger name="log4j.rootLogger" additivity="false">
<level value="DEBUG"/>
<appender-ref ref="DB"/>
</logger>
I have attempted to use a log4net webserviceappender from within a crm 2011 plugin (sandboxed), log4net apparently gets installed along with the plugin correctly (exception if log4net config file is malformed), but apparently the appender doesn't get called. I can call the webservice directly from within the plugin, so that part is working, but can't figure out what might be wrong with log4net.
Does anyone know of a step by step for using log4net with crm and/or have a good idea as to why the webserviceappender doesn't get called?
Thanks
EDIT: Including log4net.config file upon request.
<!-- WebService parameters. -->
<param name="Url" value="http://my-internal-server/errorlog/ErrorHandler.asmx" />
<param name="TimeoutSeconds" value="60" />
<!-- Proxy parameters. -->
<param name="UseProxy" value="false" />
<param name="ProxyUrl" value="http://myproxy:3128" />
<param name="ProxyBypassOnLocal" value="true" />
<param name="ProxyUseDefaultCredentials" value="true" />
<param name="ProxyCredentialsDomain" value="OFFICE" />
<param name="ProxyCredentialsUserName" value="MyUser" />
<param name="ProxyCredentialsPassword" value="MyPassword" />
</appender>
<root>
<level value="Info" />
<appender-ref ref="WebServiceAppender" />
</root>
It looks like you have deployed the configuration file on disk. This is not the ideal place as you have to deal with different requirements for the different modules.
To simplify the deployment of plugins, which need additional configuration, you have the possibility to pass configuration values to the plugin constructor. You should pass the configuration and configure log4net at runtime. See how to write the plugin constructor.
Another option is to use the webressources of Dynamics CRM 2011. See this blog article which describes all available options.
I'm new to log4net and I'm not quite sure how to set up my app.config correctly when there are multiple loggers in a dll. Well I do but I'm wondering if there is an easier way when there are 10-20 different loggers. It may also be that I just don't understand this.
Ok so let's say the dll uses the following loggers (it's actually about 20 different statements like this):
private static readonly ILog log = LogManager.GetLogger(typeof(XmlConfiguration));
private static readonly ILog log = LogManager.GetLogger(typeof(ClassValidator));
Does this mean I need to do something like this in my app.config (I have omitted appenders for brevity)?
<logger name="XmlConfiguration" additivity="false">
<level value="DEBUG"/>
<appender-ref ref="FileLog"/>
</logger>
<logger name="ClassValidator" additivity="false">
<level value="DEBUG"/>
<appender-ref ref="FileLog"/>
</logger>
Can I configure it somehow such that each logger exposed by a particular dll or partial namespace (loggers in dll are under several different namespaces but have a common root namespace) all go to the same logging source (file, console etc)?
Yes, you are correct. You can set different login levels for different dlls by configuring multiple loggers :
Here is an example i have used successfully :
<!-- ALL|DEBUG|INFO|WARN|ERROR|FATAL|OFF -->
<root>
<level value="Error"/>
<appender-ref ref="RollingLogFileAppender"/>
</root>
<logger name="NHibernate">
<level value="ERROR" />
</logger>