Log file in Dynamics Nav
Ploeg
Member Posts: 70
Howdy-ho fellow NAV'ers,
I would like to know if there is a log file available for/in Dynamics Nav in which I can find errors or warnings? My searchings across the internet haven't been very succesfull.
If there is no log file I'm going to try and build my own log. ](*,)
I would like to know if there is a log file available for/in Dynamics Nav in which I can find errors or warnings? My searchings across the internet haven't been very succesfull.
If there is no log file I'm going to try and build my own log. ](*,)
0
Comments
-
Errors or messages from the NAV client are not logged but only displayed on the user's screen.No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0
-
you can create your own log file relatively easy by using this structure
IF NOT CODEUNIT.RUN THEN myerrortext := GETLASTERRORTEXT;
and putting your whole process within the run trigger of the codeunit. Of course you can wrap whatever you want in the onrun trigger (another codeunit, some function in tables, etc. etc.). Just be be very careful to keep the transaction (if any) consistent.
Also, if you open some transaction in your "wrapper" codeunit (you write some table), and you want to recursively use the structure i've said, likemytable.findset; repeat //COMMIT; // you should place a commit here... IF NOT CODEUNIT.RUN THEN myerrortext := GETLASTERRORTEXT; COMMIT; // ...or here until mytable.next = 0;you have to run a commit at every loop (this is enforced by NAV).
Once you practice with this structure, you'll want to use it for every "interface-with-third-party-products" process you create
. It's very powerful if used wisely.
If you have some doubts, just ask (or better search mibuso)...but I encourage you to bang your head on it for a day or so
0 -
Ploeg wrote:
If there is no log file I'm going to try and build my own log. ](*,)
Why?David Singleton0 -
Thanks for the quick replies. So, a homemade log it is.
@David Singleton - I want to use this to keep track of any errors that pop-up to make testing and bug-fixing less dependable on customer input. And in time I want to expand the log with delete and modify messages, just to "monitor" user actions so we can tell them they have been morons.0 -
Ploeg wrote:Thanks for the quick replies. So, a homemade log it is.
@David Singleton - I want to use this to keep track of any errors that pop-up to make testing and bug-fixing less dependable on customer input. And in time I want to expand the log with delete and modify messages, just to "monitor" user actions so we can tell them they have been morons.
Ah so basically a reallocation of the Training Budget to the Development budget.
I never really understood why people are so opposed to training in Navision. I guess the old rule applies,a man with a hammer sees every problem as a nailDavid Singleton0 -
This is partially true. But I have two reasons to want it:
1- my own practice and experience
2- quality control of our code and modules
So in ideal circumstances it would give us a log without errors and but with delete and modify actions of users.0 -
any way....
i can create txt file if error
but how to catch the error message to put it in the log file?
thanks0 -
@juklifri: GETLASTERRORTEXT function!
and back to the original topic: I explained how to log an error refers to the fact i was supposing you wanted to monitor and log one single process, not the entire application.
I probably misunderstood your post. "If codeunit.run" traps the error without showing it, but you, instead, want to write every error that pops up to the user, isn't it? in the latter case, David's suggestion is the way to go (or an homemade log, if you have big time to spend and test!)0 -
Only solution I can think of is timer saving GETLASTERRORTEXT if not empty and not already stored. But I am not sure if it can catch everything and will be problematic to debug anything with stop at triggers enabled.0
-
Belias wrote:@juklifri: GETLASTERRORTEXT function!
and back to the original topic: I explained how to log an error refers to the fact i was supposing you wanted to monitor and log one single process, not the entire application.
I probably misunderstood your post. "If codeunit.run" traps the error without showing it, but you, instead, want to write every error that pops up to the user, isn't it? in the latter case, David's suggestion is the way to go (or an homemade log, if you have big time to spend and test!)
when the error come, it cant execute the code
IF NOT SH.INSERT(TRUE) THEN
StrLine2 := GETLASTERRORTEXT;
when i want to insert, it has redundant data
then it cant execute the next code0 -
because there's an error within the oninsert trigger, which is not related to what help online says:
If you have an ERROR('A') in your oninsert trigger, you will get the error message and stop execution and rollback.If you omit this optional return value and if the record cannot be inserted, a run-time error occurs.
On the other hand, If you use an "IF sh.INSERT(FALSE) THEN" instruction, you will never ever got an error in the GETLASTERRORTEXT, because there's no error at all. becauseIf you include the return value, you must handle any errors.
To try this functionality, write a new codeunit and do this in the onrun trigger:ERROR('thisismyerror');create a new report and do anIF not myjustcreatednewcodeunit.RUN then MESSAGE(getlasterrortext);
0 -
Thanks for all the helpful pointers. I think, for the moment, I'll go for the log which monitors just some of the functions/triggers (Belias' method). That way we can still check some of our less stable pieces of code.
I'll send MS a request for this, signed, stamped and sealed... in triplicate.0 -
We talked with you about a """tool""" to manage any type of error: i want to remark that is dangerous if not used wisely. Be very very careful to use it. I don't know what will you wrap in the "IF codeunit.run then", so i cannot give you a better suggestion than test, test, test and check data integrity of the involved tables, especially during recursive processes (most common problem is unwanted inserts/modifies). And also, remember that you want the user to receive the popup error!for this,
ERROR(GETLASTERRORTEXT);
should do the job0 -
Belias wrote:because there's an error within the oninsert trigger, which is not related to what help online says:
If you have an ERROR('A') in your oninsert trigger, you will get the error message and stop execution and rollback.If you omit this optional return value and if the record cannot be inserted, a run-time error occurs.
On the other hand, If you use an "IF sh.INSERT(FALSE) THEN" instruction, you will never ever got an error in the GETLASTERRORTEXT, because there's no error at all. becauseIf you include the return value, you must handle any errors.
To try this functionality, write a new codeunit and do this in the onrun trigger:ERROR('thisismyerror');create a new report and do anIF not myjustcreatednewcodeunit.RUN then MESSAGE(getlasterrortext);
hi Belias,
the problem is i create this code in codeunit
and i put the condition code in C# webservice, not from NAV it self
so I a little bit confuse where should i put thisIF not myjustcreatednewcodeunit.RUN then MESSAGE(getlasterrortext);
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions


