2

I'm using a custom ECL connector, similar to the Flickr example that can be found here

My problem is that I'm trying to log something to either EventViewer, File System, with Tridion Logger, nothing seems to be working. I recompile my dll, uploaded in the server, I even restart it and nothing in any of those places.

I'm using something like to log:

namespace MyProvider
{
    using System;
    using System.Diagnostics;
    using System.IO;

    using Tridion.ExternalContentLibrary.V2;

    public class EventViewerWriter : EventLog
    {
        private const string LOG_SourceName = "Tridion";

        private const string LOG_SysLogName = "Application";

        private bool _isInitialized = false;

        public EventViewerWriter()
            : base()
        {
            this.Initialize();
        }

        public void Initialize()
        {
            if (this._isInitialized)
            {
                return;
            }

            this.BeginInit();
            this.EndInit();

            if (!SourceExists(LOG_SourceName))
            {
                CreateEventSource(LOG_SourceName, LOG_SysLogName);
            }

            this.Source = LOG_SourceName;
            this.Log = LOG_SysLogName;
            this._isInitialized = true;
        }

        public void Write(string eventWritten)
        {
            try
            {
                System.Diagnostics.Trace.Write(eventWritten + " tracing id");
            }
            catch (Exception)
            {
            }

            try
            {
                // Tridion Logger
                Provider.HostServices.LogMessage(LoggingSeverity.Warning, eventWritten);
            }
            catch (Exception)
            {
            }

            try
            {
                this.WriteEntry(DateTime.Now + " - " + eventWritten, EventLogEntryType.Error);
            }
            catch (Exception)
            {
            }

            try
            {
                var currentDir = Path.GetDirectoryName(Environment.CurrentDirectory);
                var filePath = Path.Combine(currentDir, "Test.txt");

                // File System    
                using (var file = new StreamWriter(filePath))
                {
                    file.WriteLine(DateTime.Now + " - " + eventWritten);
                }
            }
            catch (Exception)
            {
            }
        }
    }
}

Note: I know I should not use empty catch, but it's a way here only to log in all cases.

UPDATE

Already tried to change the Tridion.ContentManager.Config file and add a new listener like this:

 <add switchValue="All" name="Tridion.Logging.LoggingCategory.Tracing">
    <listeners>
      <add name="Trace File" />
    </listeners>
 </add>

and writing something like this in code:

        Tridion.Logging.Logger.Write("DllTest", "DllTest", Tridion.Logging.LoggingCategory.Tracing, TraceEventType.Error);

But didn't work either. Nothing is logged.

  • If you are getting errors, why are you suppressing them with an empty try/catch? First step to troubleshooting this should be to remove those and try again. Then see if you get errors and take it from there. – Peter Kjaer Mar 17 '17 at 9:14
  • Ì'm doing that so in case there is an error (not because of something in the code of the dll but because of writing permission or similar during the logging, it will fallback to the next try of logging with in a different way. – polonskyg Mar 17 '17 at 13:57
  • And right now you don't know if it fails or if your code is never run. So perhaps temporarily you could comment that out? If you don't want to do that, try putting in a 'throw new Exception("ECL connector called!")' and see if you get that error at least. – Peter Kjaer Mar 17 '17 at 16:25
1

The problem was that the incorrect dll was being used...we thought that the dll of the ECL was the one in \Tridion\External Content Library\AddInPipeline\AddIns[Your Library] but it was not...the one being used was the one in: \ProgramData\SDL\SDL Tridion\External Content Library\AddInPipeline\AddIns[Your Library].

Thanks for all the answers.

| improve this answer | |
0

please try this Tracing & Logging - Tridion CM Server

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.