0

I am writing an Eclipse plugin and want to use tinylog in my plugin code. I tried this:

1). modified Eclipse config file (eclipse.ini) to add this line: -Dtinylog.configuration=C:\eclipse-cpp-2018-09-win32-x86_64\eclipse\tinylog.properties

2). content of tinylog.properties:

writer          = file
writer.level    = debug              
writer.file     = C:\eclipse-cpp-2018-09-win32-x86_64\eclipse\log.txt
writer.charset  = UTF-8             
writer.append   = true 
writer.buffered = true

After launching Eclipse and run my plugin, I couldn't see log.txt

BTW, my tinylog version is of 1.3.6

Martin
  • 598
  • 1
  • 4
  • 27
  • The eclipse.ini is only used by plug-ins installed in your main Eclipse installation - have you done that? Or are all you testing the plug-in using 'Run As > Eclipse Application' which starts a separate Eclipse with a separate ini file. – greg-449 Apr 20 '20 at 08:53
  • I installed my plugin under eclipse's dropins folder so that the plugin looks like a thirdparty one. then I restarted Eclipse. – user2622305 Apr 21 '20 at 02:49
  • keen to hear any suggestion. – user2622305 Apr 22 '20 at 08:24
  • I tried to put my plugin under plugins folder, the result is the same. – user2622305 Apr 23 '20 at 02:39
  • Hope some Eclipse ans Eclipse plugin and tinylog experts can give some suggestions – user2622305 Apr 27 '20 at 02:50
  • I raised similar discussion/help in Eclipse forum. https://www.eclipse.org/forums/index.php?t=rview&goto=1826693#msg_1826693 If u checked the attached files there, you can see Eclipse can get tinylog.configuration value correctly. – user2622305 Apr 30 '20 at 08:37
  • Could you provide a minimal example plugin as GitHub project to reproduce your issue? – Martin May 03 '20 at 09:11
  • I'd like to upload my sample project. Where can I put it? I modify src from https://github.com/umlet/umlet and followed https://www.umlet.com/faq.htm steps: How to start UMLet as Eclipse-Plugin? Download the "com.umlet.plugin*.jar" file and copy it to Eclipse's plugin directory. to test. – user2622305 May 04 '20 at 02:35
  • I sent to Martin's email box and I use NetBeans to build – user2622305 May 04 '20 at 02:50
  • forgot to mention that you may need to run the plugin for Eclipse CDT (C++) build – user2622305 May 04 '20 at 10:54

1 Answers1

0

You are using tinylog 1 with a configuration for tinylog 2. The correct configuration for tinylog 1.3.6 would be:

tinylog.writer          = file
tinylog.writer.level    = debug  
tinylog.writer.filename = C:\eclipse-cpp-2018-09-win32-x86_64\eclipse\log.txt
tinylog.writer.buffered = true
tinylog.writer.append   = true

In tinylog 1.3.6, the charset cannot be defined in the configuration. Instead, tinylog 1 will use the default charset for your system. The manual for tinylog 1 can be found here: https://tinylog.org/v1/configuration

Update: I just uploaded a working minimal example project on GitHub: https://github.com/pmwmedia/tinylog-eclipse-plugin-example. It contains an Eclipse plug-in that uses tinylog 1.3.6 as logging framework.

Martin
  • 598
  • 1
  • 4
  • 27
  • I used your configuration with tinylog.writer.buffered = false.
    It's improving that log file was created but it was empty. the logging stmt is so simple and easy to use, I couldn't figure out where the problem it could be in my code. Initially buffered was set to TRUE and later to be FALSE. log file always empty.
    Where did you test your example? Eclipse Java version or Eclipse CDT version. Hope your example run well in Eclipse CDT version as well.
    – user2622305 May 06 '20 at 02:42
  • how to build your example? I got this error:
    Failed to load p2 metadata repository from location http://download.eclipse.org/releases/2020-03: No repository found at http://download.eclipse.org/releases/2020-03
    – user2622305 May 06 '20 at 03:34
  • I changed to tinylog version 2.1.1 and now it's working. thanks Martin – user2622305 May 06 '20 at 04:08
  • 1
    I set buffered FALSE but I have to quit Eclipse before I can see log file being populated. I raised the question in Eclipse forum. – user2622305 May 06 '20 at 04:31