Thursday, July 18, 2013

APEXposed en Montreal - Sept 10/11


This fall ODTUG will be in Montreal for the 2nd annual APEXposed conference. Like last year, there's a star-studded lineup of speakers including Oracle's Director of Software Development, APEX's product manager, and Oracle ACE and ACE Directors. The one difference compared with last year is that we have some local speakers from Montreal and Toronto.

Some of the presentations that I'm looking forward to are:

- Joel Kallman's (Oracle Director of Software Development) talk on APEX 5.0, giving us an inside look of what's coming up in the near future.
- David Peake's (APEX Product Manager) talk on how to leverage some of the new features in 12c with APEX.
- Roel Hartman's (Director at APEX Evangelists) presentation on building mobile applications in APEX.
- Steve Feuerstein's (Dell) keynote. I just talked to him about it, should be great!

And, as shameless plug, I'll be giving two talks: "Instrumenting your PL/SQL and APEX Applications" and "APEX Development Best Practices". I'm really excited about the talk on code instrumentation as I'll be highlighted some of the new features that I've integrated into the 2.0.0 version of Logger and also share some of the new upcoming features.

If you're interested and yet haven't already registered for the conference you're in luck. It's still not to late to sign up for this 2 day (September 10th and 11th) conference. To register simply go to http://www.odtug.com/apexposed and sign up.

See you in Montreal!

Friday, July 5, 2013

It's up to You - Oracle and APEX Open Source Projects

At ODTUG Kscope 13 last week I got to moderate the APEX Lunch & Learn experts panel. One of the questions that came up was when a certain feature was going to be added to Peter Raganitsch's  APEX Developer Addon.

This sparked a bit of conversation around open source projects in the Oracle and APEX communities. They're a few people who create and maintain these open source projects. Unfortunately they're not a lot of other people who contribute to these projects. Because of this, projects don't get upgraded and enhanced as quickly as they could.

It's up to all of us in the community to enhance open source projects. Next time you need a new feature added to a project, instead of asking for it, I encourage everyone to add it yourself then contact the developer with the changes so it can be implemented to the project.

On a personal note, I'm heavily involved with several open source projects. The two most popular ones are Logger and the ClariFit APEX Plugins. I just moved the ClariFit APEX Plugins to GitHub yesterday to make it easier for others to contribute to.


Tuesday, June 4, 2013

Logger 2.0.0 - Released!

After several months in Beta, I'm please to announce that Logger 2.0.0 is now officially released! You can download the zip file from the 2.0.0 release page.

Over the past few months I've blogged about some of the significant changes we've made to Logger. Here are all the articles describing some of the new functionality:
The upgraded help document on the main Github page contains all the detailed information about Logger as well as examples. In the future, I'll be looking at moving it towards the Wiki page for better organization but for now it should do.

If you've never used it before check it out, best of all it's free and open source!

Wednesday, May 8, 2013

Logger 2.0.0 - Session Specific Logging - Advanced Features

In preparation for the release of Logger 2.0.0 I've decided to write a few posts highlighting some of the new features. 

In my previous post I covered how to set and unset session specific logging based on the Client Identifier. In this post I'll cover some advanced options for this functionality. Before continuing, please be sure to read the previous post or else this won't make sense.

In the previous post the demo code to set a session specific logging level only used two parameters: the logging level and the Client Identifier. In logger.set_level they're actually four parameters:

p_level

This is the level to set. If p_client_id is null then it will set the system level configuration in logger_prefs > LEVEL.


The additional parameters are only valid if p_client_id is defined.

p_client_id

If not null, will apply p_level for the specific client_id only. If null then p_level will be applied for the system level configuration.

p_include_call_stack

Determines if the call stack should be stored. If null then will use the default setting in logger_prefs > INCLUDE_CALL_STACK. Valid values are TRUE and FALSE (strings).

p_client_id_expire_hours

Will end session specific logging after set hours. If not defined then the default setting will be used logger_prefs > PREF_BY_CLIENT_ID_EXPIRE_HOURS. Note that this will not be exact as a job is run hourly to clean up expired session specific logging that has expired for a given client_id. Instead of waiting for the job to clean up expired sessions you can explicitly unset them.


How to View All Client_id Settings

To view the system level settings you can use the logger.status procedure. There was debate as to whether or not we include all the client_id settings in this procedure. In the end we did not include it list them in this procedure as the list may get very long. To view all the session specific logging configurations use the following query:
select *
from logger_prefs_by_client_id;

Renewing

When calling logger.set_level with a client_id that already exists in logger_prefs_by_client_id it will update the values and update the expiry date (i.e. you extend the setting).

Tuesday, May 7, 2013

Logger 2.0.0 - Enable Session Specific Logging

In preparation for the release of Logger 2.0.0 I've decided to write a few posts highlighting some of the new features.

One of the most common feature request for Logger has been the ability to enable logging (or setting the logger level) for a given session. This post covers how to set and unset session specific logging.

Logger Levels

There is no "on/off" switch for Logger. Instead, like most other logging and code instrumentation tools, it supports multiple levels. This allows developers to turn up and down the amount of logging. In most development systems the logging level is set to debug mode and in most production instances it's set to error mode. This means that in production only items that are explicitly logged using logger.log_error will be stored. For more information read the configuration section of the documentation.

Setting the Logger Level

Prior to Logger 2.0.0 you could only configure the logging level for the entire schema. To following code snippet highlights this:
exec logger.set_level('DEBUG');

begin
  -- All of these will be logged
  logger.log('Logging log level');
  logger.log_information('Logging information level');
  logger.log_warning('Logging warning level');
  logger.log_error('Logging error level');
end;
/

exec logger.set_level('WARNING');

begin
  logger.log('Logging log level'); -- Not stored
  logger.log_information('Logging information level'); -- Not stored
  logger.log_warning('Logging warning level'); -- Stored
  logger.log_error('Logging error level'); -- Stored
end;
/
What happens in production systems when a user is experiencing some issues and you want to see all their logging information? The only way to do this before was to set the logging level to debug mode and the entire schema would be affected. This could slow down all the applications in the schema which is an undesired affect.

Setting by Session
 
The term "session" is a bit misleading. Since more most Oracle applications are stateless it's not realistic to enable logging for a specific Oracle session (SID). Instead Logger uses the client_identifier (also referred to as client_id). Client identifiers can easily be configured and are commonly used in stateless applications. For example, APEX sets the client_id with: :APP_USER || ':' || :APP_SESSION

The following example demonstrates how to enable "session" specific logging in Logger:
-- Connection 1
exec logger.set_level ('ERROR');

begin
  logger.log('will not get stored');
  logger.log_error('will get stored');
end;
/

select id, logger_level, text, client_identifier
from logger_logs_5_min;

  ID LOGGER_LEVEL TEXT                 CLIENT_IDENTIFIER
---- ------------ -------------------- --------------------
  13            2 will get stored      


-- Connection 2 (i.e a different connection)
exec dbms_session.set_identifier('logger_demo');

exec logger.set_level('DEBUG', sys_context('userenv','client_identifier'));
-- Or could have used: logger.set_level('DEBUG', 'logger_demo');

begin
  logger.log('will get stored');
  logger.log_error('will get stored');
end;
/

select id, logger_level, text, client_identifier
from logger_logs_5_min;

  ID LOGGER_LEVEL TEXT                 CLIENT_IDENTIFIER
---- ------------ -------------------- --------------------
  14           16 will get stored      logger_demo
  15            2 will get stored      logger_demo
Unsettting by Session

When setting a session specific logging level, Logger will apply an expiration time to it. By default  this is set to 12 hours but can be configured by setting the logger_prefs value:  PREF_BY_CLIENT_ID_EXPIRE_HOURS  You can also pass in the time using the parameter p_client_id_expire_hours. If you don't explicitly unset a specific session then logger will automatically clean up these sessions after the desired time.

They're three ways to explicitly unset session specific logging:
-- Unset by specific client_id
exec logger.unset_client_level(p_client_id => 'logger_demo');

-- Unset all sessions that have expired
exec logger.unset_client_level;

-- Unset all sessions (regardless of expiration time)
exec logger.unset_client_level_all
Summary

By setting session specific logging you can allow for an individual connection to have logging enabled without affecting the rest of the applications in the schema.

They're some other interesting features in session specific logging that I wasn't able to fit this article. In the next article I'll discuss these features.