0

是否有任何扩展/贡献项目向 NLog 添加了多个扩展,例如自动记录当前方法及其参数?例如:

    public void RegisterUserForPromotionalMaterialIfNotAlready(string email, string name, string telNo)
    {
        _log.Debug(_log.GetCurrentMethodAndParameters());
    }

例如,这将导致它说日志记录RegisterUserForPromotionalMaterialIfNotAlready(test@test.com, 'Test Name', 'Test Tel')

4

1 回答 1

1

This is not possible without an interceptor implemented on the method itself. There is no way to programmatically sniff parameter values using just the .Net framework.

Here are some options for creating interceptors:

http://www.castleproject.org/projects/dynamicproxy/

http://www.postsharp.net/aspects

于 2013-06-20T16:17:25.407 回答