Hurence / opc-simple

OPC made simple
Apache License 2.0
17 stars 9 forks source link

roc.DefaultConnection log level #3

Open vdeters opened 5 years ago

vdeters commented 5 years ago

Hello, I'm seeing log messages like this:

Jul 26, 2019 4:19:10 PM rpc.DefaultConnection processOutgoing INFO: Sending REQUEST

...how can I control this log level? I have found these methods:

JISystem.setInBuiltLogHandler(false);
JISystem.getLogger().setLevel();

...but how can I get the JISystem instance?

Thanks!

MiniPlayer commented 5 years ago

Hello, What version are you using ? The best way to change log level in an application is to use a configuration file. We are using slf4j as you can see in the pom file :

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.12</version>
        </dependency>

Maybe you will have to add an implementation of slf4j as indicated in their documentation https://www.slf4j.org/docs.html In test we added this dependency

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.1.3</version>
            <scope>test</scope>
        </dependency>

Then in test you should be able to use log config file of logback.

May I ask why are you using our library ? What is your use case ? Maybe we can help you to achieve what you are trying to do ?

amarziali commented 2 years ago

👋 Hi. The PR mentioned above shows an example of how to control what is logged by the opc-da subsystem.

TL;DR jInterop uses java.util.logging. In order to make it working with slf4j you need to bridge it. First you need to declare the dependency for the bridge

<dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
            <version>1.7.36</version>
            <scope>runtime</scope>
        </dependency>

The statically init it:

static {
        SLF4JBridgeHandler.removeHandlersForRootLogger();
        SLF4JBridgeHandler.install();
    }

Then configure the logger level as usual.

Best,

Andrea

duduyoyo commented 1 month ago

J-Interop can't work properly after Microsoft applied DCOM hardening. You can check link here on this issue.

Alternatively, you can try this solution to retrieve OPC data back in Java. It utilizes network transportation layer to access data, so there is no 3rd party Java library or SDK required. IMO, it is simple and straightforward. Cheers!