简体   繁体   English

Log - vb.net到java

[英]Log - vb.net to java

Can anybody explain what Log means in vb.net code? 任何人都能解释一下Log在vb.net代码中的含义吗? Is it the Logarithm function or some other log event. 是Logarithm函数还是其他一些日志事件。 I did some search on this and I understood that this was for the Logarithm part. 我对此进行了一些搜索,我理解这是针对Logarithm部分的。 However, I do not understand the below line of code if I apply Logarithm to it. 但是,如果我将Logarithm应用于它,我不理解下面的代码行。

tmp=pBuffer(5)+4
Log("tmp:" & tmp)

Can anyone explain this line of code and what is the equivalent java for the same? 任何人都可以解释这行代码和相同的java是什么?

This Log means log event,I think. 我想这个日志意味着日志事件。 Just for print the tmp value. 只是为了打印tmp值。

That line of code looks to be logging an event to a log file (or console) rather than the Logarithm mathematical operation. 该行代码看起来是将事件记录到日志文件(或控制台)而不是Logarithm数学运算。

There are many ways to do logging in Java, but the simplest (though not the nicest) is to do the following: 有很多方法可以用Java进行日志记录,但最简单的(尽管不是最好的)是执行以下操作:

import java.util.logging.Logger;

public class Example {

    private static final Logger log = Logger.getLogger(Example.class.getName());

    static void doStuff(int[] pBuffer) {
        int tmp = pBuffer[5] + 4;
        log.info("tmp:" + tmp);
    }

    public static void main(String[] args) {
        doStuff(new int[] {0, 1, 2, 3, 4, 5});
    }
}

I've translated your example code verbatim as the function doStuff . 我已将您的示例代码逐字翻译为函数doStuff If you run it, you'll get something like the following printed to the console: 如果你运行它,你将得到类似以下内容打印到控制台:

12 17, 2012 4:47:01 PM Example doStuff
INFO: tmp:9

This code uses Java's built-in logging facility, which I have not used. 此代码使用Java的内置日志记录工具,我没有使用过。 If you need sophisticated logging functionality, I recommend SLF4J or log4j . 如果您需要复杂的日志记录功能,我建议使用SLF4Jlog4j

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

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