Rotating Logfile

Author: standaards.development@tui.nl (tuisd)

Hi everyone, I want to launch an idea to improve the logging within Uniface. At this moment there are possibilities in the ASN-file to set the $ioprint to your own desired level. But when your $ioprint is having a high value, this results in large log-files which are time-consuming when analyzing problems. Even in production environments where logging is kept to a minimum log files can get very big. So it would be nice to have the next two additional options for managing the Uniface log file. These options are: 1. Size restrictions 2. Age restrictions Ad 1: After the size specified in the ASN file a new log file will be created. The old log file will be saved under it?s current name with an additional date/time stamp. The size from the log file can vary between for example 1 and 1000 MB. Ad 2: If you want to have for example a new log file every day at 12.00, it would be nice to have an option to set the Age for the log file. This value could range from 1 to 31 days or another user defined value. If the value is set to e.g. 2 days after this period a new log file will be created and the old one is saved with a date time stamp. Especially applications which must be available 24/7 can profit from these enhancements. These applications nowadays are often integrated in a complex IT-architecture. There are often many (XML) connections with other applications. The 24/7 demand result in a low number of restarts for these applications. In our case there will be a maximum of 4 restarts per year, so log files can get big even with minimal logging. When the system is not available because of a crash or other reason you need to find the problem as fast as possible to minimize downtime. Therefore you can directly profit when you only have to analyze & transfer the current log file to your local environment. A size limited log file can be analyzed much faster. It also gives you the opportunity to work with al higher log level in production environments, so problems can be found faster. I hope there are more customers who see the benefits from these wish. Please let know, so we can get this functionality realized! Greetings, Damiejel Hering TUI Netherlands

8 Comments

  1. This sounds like a nice idea, its nice to be able to use %p in the log file name to get the process ID, but would be even nicer to be able to use other variables i.e. %d for date, %t for time process started etc.


    Author: jackthomas (jack.thomas@tribalgroup.co.uk)
  2. did u know, that DATE already can be displayed by default? ... its controlled by the .asn file! Furthermore a log-rotation surely is nice, when there is so much to be logged. But isnt it easier to let an external tool do this? Lets call it a service, that checkes date and size of the specific logfile and "moves" it to a new name? Uniface will create a new file when writing to the handle! Many Linux/Unix tools do so for webserver logs. Maybe this is an idea to follow -GHAN-


    Author: -GHAN- (hansen@ahp-gmbh.de)
  3. How does this work (putting the date in the filename)? I know that the date is put in the first line of the putmess file, but it would be nice to have it in the title. I would like to see the ability to log rotate in Uniface rather than as an external tool. Just for simplicitys sake.


    Author: jackthomas (jack.thomas@tribalgroup.co.uk)
  4. Just to have the feature right now: if you want it inside uniface, what about to check the size of the logfile from time to time and SPAWN the rename (or do it via OScommand, or ...) Success, Uli


    Author: ulrich-merkel (ulrichmerkel@web.de)
  5. Just to give the needed feedback: "... the date is put in the first line of the putmess file..." This is what i meant! So this is no help for you- sorry! -GHAN-


    Author: -GHAN- (hansen@ahp-gmbh.de)
  6. Let me support this wish, especially the point 2 (age restrictions). Quite similar as JTi server logging works (you can set logging level and maintenance for days and size in MB - even at runtime, no restart required). Zdeněk Socha FULLCOM systems, s.r.o.


    Author: sochaz (zdenek.socha@fullsys.cz)
  7. Dear Damiejel,

    Rotating log (and trace) files are available as of the version 9.3.02 patch P217 and the version 9.4.01 patch R108. The doc (Uniface Library) has not been updated yet, but bellow you can find a draft version of how it will be documented (shortly) - the same applies to $TRANSCRIPT_LOG_FILE.

    Hope this helps.

    Best regards,
    Daniel

    *** Usual disclaimer ***

    Updated July 4, 2011: the different options for creating a rotating log file (Filename, totalsize, and count) need to be seperated with a comma

    **********

    $PUTMESS_LOG_FILE

    Copy the message frame contents to one or more files.

    Syntax

    $PUTMESS_LOG_FILE {=} Filename{Id} | {/append}

    $PUTMESS_LOG_FILE {=} Filename {, totalsize= n} {, count= p}

    $PUTMESS_LOG_FILE {=} {"}NONE{"}

    Arguments

    Argument

    Meaning

    Filename

    Full path name to the output log file; can have a maximum length of 64 characters.

    Id

    Specify an individual log file with one or more of the following identifiers.

    • %p—process ID of the started application. If specified, /append is ignored.
    • %t—time stamp. Using this adds an extra performance penalty, because the file names must also be saved.
    • %h—host name
    • %u—user name

    totalsize= n

    Total disk space in kilobytes that can be used for all rotating log files together. This size will not be exceeded. If not specified, the default value is 10000 (10 MB).

    count= p

    Number of files used in rotating log files. The minimum value of count is 2. There is no maximum.

    However, there is a lower limit to the log file size of 3 KB. If the combination of totalsize and count produce a file size that is less than that, the count will be reduced to achieve the minimum file size.

     Note:  Rotating through a large number of files imposes a large overhead and performance penalty.

    /append

    Append any message frame information to the specified Filename.

    NONE

    Do not create log files for Uniface Router or Uniface Server processes. If specified, use uppercase.

    Defaults

    Assignment file: Any application assignment file
    Section: [SETTINGS]
    Default value: None

    Description

     Note:  It is recommended that you use $PUTMESS_LOG_FILE only during development and testing. Using it in a production environment can result in many large log files that use up valuable disk resources.

    $PUTMESS_LOG_FILE directs a copy of the message frame information for the application to a log file Filename. The file contains a complete record of all output to the message frame, that is, the file is not cleared when the message frame is cleared. This means the log file can become very large if a large application is run. To control this, consider using rotating log files.

    When a new file is created, a file banner is written to the file with information about the application. For rotating log files each banner line starts with the [logsegmentN]. For non-rotating files, the banner starts with [startup].

    If the Filename already exists when the application starts using $PUTMESS_LOG_FILE, the file's contents are cleared, unless /append is used, in which case the logging information is added to the file.

    Rotating Log Files

    Adding the optional totalsize=n and count=p parameters enables you to use rotating log files. The first and most recent file always has the name specified in the assignment setting.

    When the file size reaches the maximum size, as determined by the totalsize divided by the count, the file is renamed, appending _1, and logging continues in a newly created file with the name specified in the assignment. When this file reaches the specified maximum size, the _1 file is renamed to _2, and the new file has _1 appended, and logging continues in a newly created file. This process is repeated until the number of log files matches the value of count, and then the oldest is deleted as new log files are created. As files are renamed, any existing file with that name is deleted.

    As the log proceeds through the rotation, the oldest part of the log is deleted. Make sure you have defined a totalsize large enough to maintain a reasonable history, otherwise error messages written earlier may be lost.

    If an error occurs during the rotation and it is no longer possible to guarantee that the total file size is below the totalsize argument, logging will stop. The error will be written to a uniface_app_type_%p.log in the working directory of the application, not in the directory specified for the $PUTMESS_LOG_FILE.

    Using /append

    You can use /append for rotating files to continue the rotation. If files exist with the same name and sequence numbers they will continue to be used.

     Note:  Never share rotating log files over multiple concurrent sessions. The size calculations will not be accurate.

    For non-rotating log files, /append can be useful when two sessions are started, either simultaneously or sequentially. The file will contain the logging information from both sessions.

    If /append is not defined, the file will contain only the logging information of the last session.


    Log Files for Multiple Server Processes

    For the Uniface Router or Uniface Server, there can be multiple server processes running concurrently, so the default behavior is always to create a unique log file for each Router and each Server instance, even if you do not specify $PUTMESS_LOG_FILE.

    If you do not want log files to be created, either for the Uniface Router or for the servers, use the NONE option of $PUTMESS_LOG_FILE in the appropriate assignment files to suppress their creation.

    Example

    In this example, if 214 were the process ID of the running application, the log file name would be named myapp214.log.

    $PUTMESS_LOG_FILE=myapp%p.log

     


    Author: diseli (daniel.iseli@uniface.com)
  8. Wouaaouhh

    That's a damn good news !


    Author: richard.gill (richard.gill@agfa.com)