-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write a log to PLC Next log file #21
Comments
I think the Log class might help in this case: This should log a message to the file /opt/plcnext/logs/Output.log. Note that, by default, DEBUG and TRACE messages are not recorded in that log file. More information here: |
Thank you for the answer. Is there maybe an example of using the methods in Log class? Specifically I am interested in how to define the format string and 'args' arguments. |
It just uses standard C# formatting. This example is based on the C# function template, and writes the value of the two input parameters to the log file: [Function]
public static class Function1
{
[Execution]
public static bool __Process(
[Input] short IN1,
[Input, DataType("WORD")] ushort IN2)
{
bool Function1 = false;
if (IN1 + IN2 == 2)
Function1 = true;
Log.Info("Hello. IN1 = {0} and IN2 = {1}", IN1, IN2);
return Function1;
}
} There's resources online that explain C# output formatting, e.g.: |
Ok, I understand now. Thanks for the help! |
One example of the feature that I find useful is writing a log to a PLC Next log file.
For example: if you catch an exception in your C# code, you could write the exception message to log file for diagnostic purposes.
Is there such possibility in PLC Next development tools?
The text was updated successfully, but these errors were encountered: