G
Guest
Hi all,
I have a question about tracking of method calls. I would like to track/log
methods in code during runtime. I thought that I can write custom attribute
which I will use in method which call I want to log and in constructor of
the attribute I will write logging functionality. But this doesn't work. No
code in attribute class is executed.
Any idea how to solve this problem?
Stepan
---------------------------------------------------------
Example:
[AttributeUsage(AttributeTargets.Method)]
public class LoggerAttribute : System.Atribute {
public LoggerAttribute () {
// here is code for logging
}
}
Usage:
public class TestLoggerClass {
[Logger]
public void DoSomething() {
// here is some cod
}
}
public class TestProgram {
public static void Main(string[] params) {
TestLoggerClass x = new TestLoggerClass();
// I want to log method calling when I do next row. But it doesn't
work
x.DoSomething();
}
}
I have a question about tracking of method calls. I would like to track/log
methods in code during runtime. I thought that I can write custom attribute
which I will use in method which call I want to log and in constructor of
the attribute I will write logging functionality. But this doesn't work. No
code in attribute class is executed.
Any idea how to solve this problem?
Stepan
---------------------------------------------------------
Example:
[AttributeUsage(AttributeTargets.Method)]
public class LoggerAttribute : System.Atribute {
public LoggerAttribute () {
// here is code for logging
}
}
Usage:
public class TestLoggerClass {
[Logger]
public void DoSomething() {
// here is some cod
}
}
public class TestProgram {
public static void Main(string[] params) {
TestLoggerClass x = new TestLoggerClass();
// I want to log method calling when I do next row. But it doesn't
work
x.DoSomething();
}
}