Log external object

Official Content
This documentation is valid for:

Log external object allows the developer to write messages in the log system in different levels, which will go to different streams.

Logexternalobject-Location_png image_2018613135750_1_png

Properties

Does not have any.

Methods

All of them allows the developer to indicate a "topic" value with the meaning of the data written.

Write method

Writes a message in the log, and optionally you can indicate a topic and the desired log level.

Return value  None
Parameters Message:VarChar(1000) [ topic:VarChar(40) , logLevel:GeneXus.Common.LogLevel ]
   

Fatal method

Writes a fatal message in the log (through the errors flow channel).

Return value  None
Parameters Message:VarChar(1000) [  topic:VarChar(40) ]
   

Error method

Writes an error message in the log (through the errors flow channel).

Return value  None
Parameters Message:VarChar(1000) [  topic:VarChar(40) ]
   

Warning method

Writes a warning message in the log (through the warnings flow channel).

Return value  None
Parameters Message:VarChar(1000) [  topic:VarChar(40) ]
   

Info method

Writes an info message in the log (through the info flow channel).

Return value  None
Parameters Message:VarChar(1000) [  topic:VarChar(40) ]
   

Debug method

Writes a debug message in the log (through the debug flow channel).

Return value  None
Parameters Message:VarChar(1000) [  topic:VarChar(40) ]
   

Events

Does not have any.

Domains

LogLevel domain

Enumerated domain with the available log levels. In order of significance:

FATAL Fatal level
ERROR Error level
WARNING  Warning level
INFO Informational level
DEBUG Debug level
OFF Log disabled
   

Example

Smart devices

Suppose you have the Default Log Level property set to "Warning", and the following code in a client-event:

Event 'Test'
    Composite
        Log.Debug(!"Debug message",!"MyCompany.Test.TestSDLoggingDebug")
        Log.Info(!"Info message",!"MyCompany.Test.TestSDLoggingInfo")
        Log.Warning(!"Warning message",!"MyCompany.Test.TestSDLoggingWarning")
        Log.Error(!"Error message",!"MyCompany.Test.TestSDLoggingError")
    EndComposite
Endevent

Then, in Android's LogCat, you will see the following messages (refer to HowTo: Enable logging for Smart Devices).

Log external object - Android example

Note that it only displays Warning and Error messages due to the Log Level property. Other messages are ignored (Debug and Info).

Note: Remember that log messages will be displayed on LogCat/XCode in online applications only when the Log external object is executed on client-side events. In such case, The Start, Refresh and Load events will print the log depending on the server-side configuration (as it is shown in the example below).

Web

Suppose you have the Log level property set to "6.All" and Log output property to "File". Then, if you write an event like this:

Event 'Test'
      Log.Write(!"Write message", !"MyCompany.Test.TestLoggingWrite",LogLEvel.DEBUG)
      Log.Debug(!"Debug message",!"MyCompany.Test.TestLoggingDebug")
      Log.Info(!"Info message",!"MyCompany.Test.TestLoggingInfo")
      Log.Warning(!"Warning message",!"MyCompany.Test.TestLoggingWarning")
      Log.Error(!"Error message",!"MyCompany.Test.TestLoggingError")
      Log.Fatal(!"Fatal message",!"MyCompany.Test.TestLoggingFatal")
Endevent

In the client.log file you will see the following messages:

LogExternal Object - NetExample

Notes

  • The following statements are equivalents: 
    msg(&string,status)
    Log.Debug(&string)
    Log.Write(&string,"",LogLevel.DEBUG)

Scope

Platforms  Smart Devices (Android, iOS), Web (.NET, Java)

Availability

This external object is available as of GeneXus 15 Upgrade 11

Best practices

When using Modules for sharing GeneXus's interfaces (e.g. an API), it is highly recommended to follow these guidelines.

  • Always include a log message on your operations, preferably in English and with no translation (using "!" notation, e.g. !"My log message") to simplify filters and searches. 
  • Add a topic to each log message indicating which object produce the message. You can use the following convention:
    !"<Company>.<Module>.<Object>"
    For example:
    !"GeneXus.GeneXus.Common.Notifications.SendNotification"
    where GeneXus is the company, GeneXus.Common.Notifications is the module (from the root), and SendNotification is the object.
  • Use Log API instead of msg("<My message>",status)

See also



Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.