How to remove the stacktrace from the standard ServiceStack error respose

扶醉桌前 提交于 2019-12-11 02:37:34

问题


I'm just getting started with ServiceStack, and I'd like to find out if it's possible to remove the stacktrace from the standard error response.

I have tried shutting off debugmode without any luck:

public override void Configure(Funq.Container container)
{
    SetConfig(new EndpointHostConfig { DebugMode = false, });
}

Thanks a bunch!


回答1:


By default the configuration below only removes the StackTrace from being externally visible in your Web Service's response:

SetConfig(new EndpointHostConfig { DebugMode = false, });

I've tested this again and it works as expected.

To disable Logging all together you can set ServiceStack to use a NullLogFactory

LogManager.LogFactory = new NullLogFactory();

Alternatively you can control the granularity of all logging by creating your own ServiceStack.Logging adapter and setting it in the same way:

LogManager.LogFactory = new MyCustomLogFactory();



回答2:


I was worried about the stack trace before and did some testing about it.

I found out that in the default case you don't need to set this option. If the project is built in Release then the stack trace is not in the response.



来源:https://stackoverflow.com/questions/8453034/how-to-remove-the-stacktrace-from-the-standard-servicestack-error-respose

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!