How to write your own trace logs

(Bart Elia) #1

Dang it @Chris_Conn you mentioned logging. Now I have to drag out my old trace / log writing tips.

Everyone knows you can create your own trace logs, just like Epicor right? :wink:

(Aaron Willett) #2

I did not know this! Can you share? :slight_smile:

(Bart Elia) #3

The magic is :

() => “Some Text”

such as the following on Ice.Tip.GetRows

If you have that trace flag in appserver.config:

It will output to your tracelog:

The trace writes are using a func for the message text. This allows for a ‘call back’ approach. e.g. - DOn’t build up your message if the trace is not active. Amazing how that speeds up things when you have hundreds of trace.writelines all over the server and are not tracing.

(Jose C Gomez) #4

This is gold @Bart_Elia, split into its own topic. Awesome sauce, is this documented somewhere ? (Other than right here , right now lol)

(Dan Edwards) #5

I know this was covered during a couple deep dive sessions at Insights starting in 2015 and included in the distributed material (Powerpoint). At that time, I never found official documentation from Epicor, but I am sure I am probably wrong.

(Bart Elia) #6

Talk to me after Insights.

(Bart Elia) #7

A couple of other trace items:

Ever want to time anything? Have it done for you

() => DoSomethingToBeTimed(),
() => “Some Message”

Also log tracing in context with the rest of the server:

             //Do Something that goes boom
        catch (Exception ex)
            throw ex;

(Tim Shoemaker) #8

adding a tracelog SHOULD be a standard Widget in the BPM tool (Just sayin!) so that we don’t have to write C# code in a BPM made of all widgets.

(Chris Conn) #9

There is so much goodness here. Thanks!

(Haso Keric) #10

Bart - does it have to be called trace://ice/mytrace or can you create your own like trace://ice/XYZTrace

(Bart Elia) #11

No worries. We made it plug-able - just add your own uri - so partners could leverage it. It was designed that way since day 1 so you would not need someone with magic framework fairy dust blessing a name.

BTW - Another nifty feature - the uri is wildcard friendly.

Imagine two uris:

WriteTraceMessage(“trace://ice/fw/session" …

If you set a trace in appserver.config:

< add uri=“trace://ice/fw/session” />
This gives you things traced in session

< add uri=“trace://ice/fw/license” />
This gives you things traced in license

< add uri=“trace://ice/fw” />
This gives you things traced in EVERYTHING under fw. Logically “ice/fw/*.*” if that makes sense.

(Bart Elia) #12

@hasokeric the trace SHOULD allow any uri but I noted a bug yesterday that we broke some areas of complete flexibility. I know that ice/Anything works. Plug in whatever you want under ice. I have a note to have system, erp and then complete flexibility checked.