简体   繁体   English

Java异常Stacktrace

[英]Java Exception Stacktrace

I'm creating application and in this application I need to write all exceptions to file. 我正在创建应用程序,在此应用程序中,我需要将所有异常写入文件。 I need to get line number of error and I'm using this to get line number: 我需要获取错误的行号,并且正在使用它来获取行号:

entry.setStackTrace(e.getStackTrace()[0].getLineNumber());

But I'm afraid, that stacktrace can be null. 但是,恐怕stacktrace可以为null。 So my Question is - can stack trace be null? 所以我的问题是-堆栈跟踪可以为空吗?

If an Exception has been thrown, the 如果引发了异常,则

e.getStackTrace()

can't be null. 不能为null。

But why you don't use the std Java Logger or the android logger for Logging outputs? 但是,为什么不使用std Java Logger或android logger来记录输出呢?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM