Whether PostSharp log attribute support ansyc meathed and how to use it to write the log to a log file? - log4net

I want to know whether the log attribute of Postsharp supports ansyc method?
I want to use the log attribute to write log infos to a file.
Can you give me a demo to show me how to write log infos to a file by using log4net?

Log attribute doesn't support async methods. You can apply it to them but it doesn't understand underlying state machine so result could be quite disappointing (e.g. method exit will be logged before first await).
Adding log aspect is easy when you use PostSharp Tools for Visual Studio. Just place the caret over code element identifier (like class name or namespace) and open smart tag (or lightbulb in VS2015), select Add logging... and walk through the wizard. It is pretty straightforward.
PostSharp itself supports only logging to console and trace. As mentioned in comments you can select other backends like log4net or nlog to store log output in files (or anywhere else).
How to configure log4net is well described here and how to configure nlog is described here.

Related

How to debug custom c# action that executes sql

I am running custom action that suppose to execute some function in provided dll.
this function connects to sql db and do some select with return, but i cannot see the return value.
How can i debug this function in dll, or check if it is really executed.
I've use C++ custom action DLLs, so I'm not entirely sure how a C# custom action DLL differs. However, I usually use the method Ondrej mentioned: logging to the MSI log file and/or message boxes that pause the custom action execution so I can attach to the process via Visual Studio.
Are you familiar with how that is done?
InstallShield has native SQL script handling for most of your needs. This will automatically give you a lot of logging in the MSI log file. However returning result sets is one thing it doesn't do.
The best thing to do is write your managed C# custom action using Windows Installer XML (WiX) Deployment Tools Foundation (DTF). This builds custom actions that appear as C++ custom actions to the Windows Installer and is fully compatible with InstallShield.
Inside of a DTF custom action you can use session.Log() to record useful debugging information in the Windows Installer log file. You can also attach a debugger to the custom action and step through it if you want. See the following for more information:
Deployment Tools Foundation (DTF) Managed Custom Actions

Log4j sorting logs

I am running one jar on unix machine and takes output of it on windows machine program using JSCH. So, i am creating log file on unix machine this will be detailed log file of jar present on unix.So, here i want to print some restricted output on unix console and take it on my windows application after executing the JAR file and all other info will go into detailed log file.So how i will print restricted output on console using log4j? what i need to do to achieve this? can anybody gives example of this?
You have to configure 2 different "appenders": a ConsoleAppender and a FileAppender, then you can direct output to one of them or both. To select which appender will receive a log item you can discriminate on logging priority (for example console could receive only ERROR and FATAL items, the log file could receive everything) and/or the class or package producing that log item. The log4j intro documentation page explains how to make this configuration.

Resource is out of sync with the file system after ACL change

This appears to be a common error for java. I searched for the error but could find nothing specific to domino and the ACL issue.
I have a couple of java classes in my database. One is a HttpServlet class, the other an IHttpServlet factory. I also added just a regular class to the db for testing.
Any time I make any change to the ACL, the servlet will no longer run. If any of the java source document are open, it shows Resource is out of sync with the file system: mydb.nsf Press F9 or Select File>Refresh to select the file. That test class also displays this message.
I need to refresh the document and rebuild to get the servlet to run.
I was going to submit this to tech support but thought I would ask here first. Hopefully it is an issue that can be easily resolved.

Mule Logs not showing

I'm trying to launch a Mule application I have written, but I cant seem to get the logs to show up when I run it from the console. When I look at the log file, I see the Mule loading process (assuming I am using the app not the service mode) but then the log goes blank. Note that the log is visible when I'm using Mule Eclipse IDE.
Sounds like your app logging configuration overrides the global one, but is also not doing what you expect. Add -M-Dlog4j.debug switch to the Mule command line to see where rogue log4j config file might be coming from.
To properly log Mule messages into a log file, you should have a category definition in your log4j.properties and refer to that in your Mule flow as:
<logger level="INFO" category="your_custom_category" message="#[payload]"/>
Try to restart the entire machine. It sounds like an Eclipse problem not a problem with your program.
May be you have not properly placed the properties file and jar file.
Place
"log4j.properties" in "WEB-INF/classes"
and copy
log4jx.y.z.jar to "WEB-INF/lib".

How to switch on/off logging using Log4net

I have logged all my applications transaction using Log4net. Is there any way I can disable and enable logging from a common place without altering the code written for logging.
I assume you want to toggle logging in your running application through code. I did not try it but I think that calling the following method should disable logging:
LogManager.GetRepository().ResetConfiguration();
To re-enable logging you would call
XmlConfigurator.Configure();
(or one of the other methods of the XmlConfigurator).
However there seems to be an issue with calling the Configure method repeatedly. I do not know if this would be a problem for you, but at least I warned you...
You can turn them off by changing the log4net config file. Specifically change the appender's level or global level to "OFF" value. See here for details
Assuming I understand your question, from the FAQ: http://logging.apache.org/log4net/release/faq.html
How do I completely disable all logging at runtime?
Setting the Threshold on the Hierarchy to Level OFF will disable all logging from that Hierarchy. This can be done in the log4net configuration file by setting the "threshold" attribute on the log4net configuration element to "OFF". For example:

Resources