Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Showcase
  4. Logger: simple, convinient and thread safe logger for Qt applications
QtWS25 Last Chance

Logger: simple, convinient and thread safe logger for Qt applications

Scheduled Pinned Locked Moved Showcase
loggingqdebug
43 Posts 14 Posters 62.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 0 Offline
    0 Offline
    01amit
    wrote on 16 Apr 2012, 21:27 last edited by
    #21

    I want to desroy the object when the button is clicked not when the application have been closed.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      aekam
      wrote on 18 Apr 2012, 11:45 last edited by
      #22

      in which version of Qt i can find these files, <Logger.h> and <ConsoleAppender.h> ??? :-?

      If you take care of inches, you won't have to worry about miles... :)

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on 18 Apr 2012, 11:58 last edited by
        #23

        [quote author="aekam" date="1334749555"]in which version of Qt i can find these files, <Logger.h> and <ConsoleAppender.h> ??? :-?[/quote]
        You can't. It's an external project. See the very first post in this topic.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maxvanceffer
          wrote on 4 May 2012, 10:46 last edited by
          #24

          How about logging size ? I searched in several Qt based logging libs ( QxtLogger, log4qt ..... ) didn't find any functions in it, related to the size of log functionality. So it will be very usefull to see this functionality !

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on 4 May 2012, 11:24 last edited by
            #25

            I don't understand the question. What do you mean with 'logging size'? Do you want to set some kind of maximum size for the log file output or something like that?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              maxvanceffer
              wrote on 7 May 2012, 07:58 last edited by
              #26

              Yes, for example : maximum log messages ( last 100 messages ) , or maximum log file size.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                maxvanceffer
                wrote on 10 May 2012, 05:52 last edited by
                #27

                I search frew several projects, and no one provide such functionality. Only log4qt, but it hard to understand, and implement.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on 10 May 2012, 08:22 last edited by
                  #28

                  Personally, I think log rotation is a separate task. It seems quite expensive to do something like limiting to the last 100 messages. It means re-writing the entire logfile for each message, as you cannot remove from the start of a file. Adding is trivial though.

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    maxvanceffer
                    wrote on 10 May 2012, 11:59 last edited by
                    #29

                    i already tried my self re-writing file and this real complex task, and heavy in time execution... but log can be very fast happend... but what, if i don't need handle a lot of messages ....

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      andre
                      wrote on 10 May 2012, 14:09 last edited by
                      #30

                      I have no idea what you just asked. Sorry.

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        cyberbobs
                        wrote on 19 Jun 2012, 13:53 last edited by
                        #31

                        IMO the most correct way to implement a log rotation is to create separate log files for every week/day/hour (choose yours interval) and to automatically remove older logs becoming obsolete. For example, Apache web server logging is organized in such a way. We've implemented that kind of log rotation for one of our projects using Logger some time ago, but I've never published those classes. The problem is I can't share the source because of some licensing restrictions (it was created by another developer working on a commercial project).

                        Anyone interested in implementing that kind of functionality (and adding it to logger mainstream code) could easily contact me via email or simply post a merge request on gitorious.

                        1 Reply Last reply
                        0
                        • C Offline
                          C Offline
                          cyberbobs
                          wrote on 6 Jul 2012, 13:01 last edited by
                          #32

                          Just merged "one important change":https://gitorious.org/cutelogger/cutelogger/merge_requests/2 (thanks goes to Pritam Ghanghas). Now LOG_DEBUG() and other similiar macros supports all the features of qDebug() and could also support the printf-like syntax so we can simply search-and-replace qDebug() with LOG_DEBUG() and QDebug or QtDebug header with Logger.h

                          Still waiting for your contributions to make Logger more useful :)

                          1 Reply Last reply
                          0
                          • D Offline
                            D Offline
                            dvolosnykh
                            wrote on 14 Nov 2012, 09:07 last edited by
                            #33

                            Just wanted to notify the project's maintainers that cutelogger doesn't compile using Qt 5 Beta2 with deprecated API turned off by default: qInstallMsgHandler() has become deprecated.

                            1 Reply Last reply
                            0
                            • C Offline
                              C Offline
                              cyberbobs
                              wrote on 14 Nov 2012, 13:46 last edited by
                              #34

                              Ok, thank you for notification. Currently there is only one project maintainer and I don't have much time for now to implement and support the Qt 5.0.0 compatibility of the project.

                              Taking a quick look through the Qt 5 beta2 headers I've noticed there is a lot of work to be done refactoring the Logger to take advantage of the extended Qt 5 logging abilities. If anyone is willing to implement Qt 5 compatibility and post it as a merge request on Gitorious the contribution will be kindly accepted :)

                              1 Reply Last reply
                              0
                              • C Offline
                                C Offline
                                cyberbobs
                                wrote on 20 Nov 2012, 09:59 last edited by
                                #35

                                Pushed "e3c2745":https://gitorious.org/cutelogger/cutelogger/commit/e3c2745c6c5f38896f87472e01ea2caf2d9e211b. Now Logger successfully builds with Qt 5 and uses some of its advanced logging feature (e.g. file/line/function name gathered in renewed qDebug and the same macros).

                                Still some work to be done to support "log categories":https://codereview.qt-project.org/#change,13226 and new Qt log formatting feature in a ConsoleAppender.

                                1 Reply Last reply
                                0
                                • O Offline
                                  O Offline
                                  oraclei
                                  wrote on 24 Dec 2012, 02:36 last edited by
                                  #36

                                  How do I enable/disable the CuteLogger?

                                  1 Reply Last reply
                                  0
                                  • C cyberbobs
                                    20 Dec 2010, 16:18

                                    Hello in there.

                                    I want to proudly present the simple logging component for the Qt applications we're internally using for some of our projects. This component is designed concerning the K.I.S.S. principle and proved itself to be very stable and convinient to use. And yes, it's thread safe and ready for using in multi-threaded applications. I really hope it would be useful for you.

                                    Here's a simple code example using it:

                                    #include <QCoreApplication>
                                    
                                    #include <Logger.h>
                                    #include <ConsoleAppender.h>
                                    
                                    int main(int argc, char* argv[])
                                    {
                                      QCoreApplication app(argc, argv);
                                      ...
                                      ConsoleAppender* consoleAppender = new ConsoleAppender();
                                      consoleAppender->setFormat("[%{type}] <%{function}> %{message}\n");
                                      logger->registerAppender(consoleAppender);
                                      ...
                                      LOG_INFO("Starting the application");
                                      int result = app.exec();
                                      ...
                                      if (result)
                                        LOG_WARNING() << "Something went wrong." << "Result code is" << result;
                                    
                                      return result;
                                    }
                                    

                                    Library is Qt 4 and Qt 5 compatible, tested on Windows, Linux and Android (LogCat support included out-of-the-box). Also you may wish to know, that it's not meant to be a separate component, but it's prepared for including to your application sources, for example, using the git submodule approach. Build scripts to use the Logger in qmake-, CMake- or qbs-based projects are included. Logger also supports using many so-called appenders at once (targeting the log stream to different places), logging categories and many other features: just see the docs :)

                                    It's distributed free of charge according to the terms of LGPL 2.1 license and can be downloaded on the project GitHub page: https://github.com/dept2/CuteLogger

                                    Rather full documentation on it is embedded into a header files and may be generated using the doxygen (Doxyfile supplied).

                                    Waiting for your comments and suggestions :)

                                    AlexorleonA Offline
                                    AlexorleonA Offline
                                    Alexorleon
                                    wrote on 6 Apr 2016, 05:37 last edited by
                                    #37

                                    @cyberbobs said:

                                    Hello

                                    Hello! How do I connect this component to my program, it is necessary to compile? I can not find a solution.
                                    I copied files but there were errors.
                                    android/log.h: No such file or directory
                                    #include <android/log.h>

                                    windows.h: No such file or directory
                                    #include <windows.h>

                                    My system Ubuntu 14.04

                                    C 1 Reply Last reply 16 Jun 2016, 11:41
                                    0
                                    • AlexorleonA Alexorleon
                                      6 Apr 2016, 05:37

                                      @cyberbobs said:

                                      Hello

                                      Hello! How do I connect this component to my program, it is necessary to compile? I can not find a solution.
                                      I copied files but there were errors.
                                      android/log.h: No such file or directory
                                      #include <android/log.h>

                                      windows.h: No such file or directory
                                      #include <windows.h>

                                      My system Ubuntu 14.04

                                      C Offline
                                      C Offline
                                      cyberbobs
                                      wrote on 16 Jun 2016, 11:41 last edited by
                                      #38

                                      @Alexorleon Replied to your question on Github. Basically, you don't need to include windows-specific or console appenders to Android project, it is already handled in pro file included in the library sources. Also, it is suggested that you will include CuteLogger sources to your project (if you store project in git repository, you can add it as submodule) and build it alongside your project instead of building it separately and adding the prebuild libraries.

                                      1 Reply Last reply
                                      1
                                      • Gregoire BorelG Offline
                                        Gregoire BorelG Offline
                                        Gregoire Borel
                                        wrote on 12 Aug 2016, 15:50 last edited by
                                        #39

                                        Hey, thanks for this library, it's really cool.

                                        I'd like to know if it was possible and safe to write in several files? I'd like to create several FileAppender's and decide in which of these files I should write.

                                        Is there any way to indicate to LOG_INFO() the FileAppender I want to write in?

                                        C 1 Reply Last reply 15 Sept 2016, 18:16
                                        0
                                        • K Offline
                                          K Offline
                                          Konstantin Tokarev
                                          wrote on 12 Aug 2016, 15:59 last edited by
                                          #40

                                          Use syslog, it's simple, convenient and thread safe, and has powerful tools to work with (e.g., syslog-ng server). Don't reinvent the wheel!

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved