I'm writing an exception logger class. My question is: what to use to mark the current method? Except it's name, cause the code will be obfuscated, so it can't be used.
Asked
Active
Viewed 330 times
3 Answers
3
You can invent your own attribute and decorate your methods with the attribute.
Something like [MethodName("WriteXMLData")]
You can then have the logger class perform some reflection on the MemberInfo object passed to it during logging.
This is a great tutorial for defining and querying your own attributes.

tenor
- 1,095
- 6
- 8
-
1Of course, if you’re going to do that, you might as well tell your obfuscator to stop renaming things. Or just stop using obfuscators entirely. – Timwi Feb 06 '11 at 23:52
0
You might want to take a look at some of the logging frameworks out there. I'm partial to NLog. It's easy to configure and has a lot of flexibility.

bshacklett
- 1,802
- 5
- 23
- 45
-1
you can get all the data u need about the specific exception, and log it to a data source:
here u can extract a little info on a given exception:
protected void Application_Error( object sender, EventArgs e )
{
Exception Exc = null;
try
{
Exc = Server.GetLastError();
if(Exc.InnerException != null)
Exc = Exc.InnerException;
// Method name + line number + column
System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(Exc, true);
string ExtraData = "Name : {0}, Line : {1}, Column : {2}";
ExtraData = String.Format(ExtraData, trace.GetFrame(0).GetMethod().Name, trace.GetFrame(0).GetFileLineNumber(), trace.GetFrame(0).GetFileColumnNumber());
// exception message
Exc.Message;
// page name
Request.Url.ToString();
// stack trace
Exc.StackTrace;
}
}

Shlomi Komemi
- 5,445
- 3
- 28
- 41