Skip to content

LUTECE-2196 : Allow to reload the log4j configuration at runtime #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ manage_caches.actionDisable=Turn off
manage_caches.actionViewKeys=View config and keys
manage_caches.buttonFlush=Flush all
manage_caches.buttonViewKeys=View config and keys
manage_caches.titleReloadLogsConfiguration=Log configuration loading
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that be "reloading" ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose the same expression as the other "reloading" button which says "Properties Loading". I don't have a strong opinion

manage_caches.titleReloadProperties=Properties loading
manage_caches.labelReloadProperties=Reload properties files
manage_caches.buttonReload=Reload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ manage_caches.actionDisable=D\u00e9sactiver
manage_caches.actionViewKeys=Visualiser les cl\u00e9s
manage_caches.buttonFlush=Vider tous les caches
manage_caches.buttonViewKeys=Visualiser les cl\u00e9s
manage_caches.titleReloadLogsConfiguration=Rechargement de la configuration des logs
manage_caches.titleReloadProperties=Rechargement des properties
manage_caches.labelReloadProperties=Recharger les fichiers properties
manage_caches.buttonReload=Recharger
Expand Down
23 changes: 23 additions & 0 deletions src/java/fr/paris/lutece/portal/web/system/CacheJspBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import fr.paris.lutece.portal.service.i18n.I18nService;
import fr.paris.lutece.portal.service.security.SecurityTokenService;
import fr.paris.lutece.portal.service.template.AppTemplateService;
import fr.paris.lutece.portal.service.util.AppLogService;
import fr.paris.lutece.portal.service.util.AppPropertiesService;
import fr.paris.lutece.portal.web.admin.AdminFeaturesPageJspBean;
import fr.paris.lutece.util.html.HtmlTemplate;
Expand Down Expand Up @@ -70,6 +71,10 @@ public class CacheJspBean extends AdminFeaturesPageJspBean
private static final String TEMPLATE_CACHE_INFOS = "admin/system/cache_infos.html";
private static final String PARAMETER_ID_CACHE = "id_cache";

// Conf
private static final String PATH_CONF = "/WEB-INF/conf/";
private static final String FILE_PROPERTIES_CONFIG = "config.properties";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you shoud not redefine these constants here, but share them with the normal intialisation process. Otherwise, there is a risk these become desynchronized

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already defined in several places as private constants... Not sure if it's useful to declare them as public constants. Maybe in fr.paris.lutece.portal.web.constants.Parameters ? but it looks like this class is for parameters of http requests.


/**
* Returns the page to manage caches
*
Expand Down Expand Up @@ -138,6 +143,24 @@ public String doReloadProperties( HttpServletRequest request ) throws AccessDeni
return JSP_MANAGE_CACHES;
}

/**
* Reload the logs configuration of the application
*
* @return The URL to display when the process is done.
* @throws AccessDeniedException
*/
public String doReloadLogsConfiguration( HttpServletRequest request ) throws AccessDeniedException
{
if ( !SecurityTokenService.getInstance( ).validate( request, TEMPLATE_MANAGE_CACHES ) )
{
throw new AccessDeniedException( "Invalid security token" );
}
AppLogService.init( PATH_CONF, FILE_PROPERTIES_CONFIG );

return JSP_MANAGE_CACHES;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to add tests that

  • ensure the CSRF protection is enforced
  • verify that the log configuration is indeed changed


/**
* Gets cache infos for all caches
*
Expand Down
4 changes: 4 additions & 0 deletions webapp/WEB-INF/templates/admin/system/manage_caches.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<@button type='submit' buttonIcon='refresh' title='#i18n{portal.system.manage_caches.titleReloadProperties}' id='reload' size='' showTitleXs=false showTitleSm=false />
<@aButton href='jsp/admin/system/CacheInfos.jsp' buttonIcon='key' title='#i18n{portal.system.manage_caches.buttonViewKeys}' size='' showTitleXs=false showTitleSm=false />
</@tform>
<@tform method='post' action='jsp/admin/system/DoReloadLogsConfiguration.jsp' class='pull-right spaced'>
<input type="hidden" name="token" value="${token}">
<@button type='submit' buttonIcon='refresh' title='#i18n{portal.system.manage_caches.titleReloadLogsConfiguration}' id='reloadLogsConf' size='' showTitleXs=false showTitleSm=false />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the button shows no text on small screens ? Since there are no tooltips on smartphone, the purpose of this button might not be obvious

Copy link
Member Author

@jonenst jonenst May 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we go with having this button on this page, then maybe we can use a single letter to disambiguate ? L and P. Or Logs and Props ? Or Logs and Properties ?
If we put this functionality in another page maybe the "reload" glyph is enough

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just display the title at all sizes ?

</@tform>
<@tform method='post' action='jsp/admin/system/DoResetCaches.jsp' class='pull-right spaced'>
<input type="hidden" name="token" value="${token}">
<@button type='submit' buttonIcon='trash' title='#i18n{portal.system.manage_caches.buttonFlush}' size='' color='btn-danger' showTitleXs=false showTitleSm=false />
Expand Down
8 changes: 8 additions & 0 deletions webapp/jsp/admin/system/DoReloadLogsConfiguration.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%@ page errorPage="../ErrorPage.jsp" %>

<jsp:useBean id="cache" scope="session" class="fr.paris.lutece.portal.web.system.CacheJspBean" />

<%
cache.init( request , cache.RIGHT_CACHE_MANAGEMENT );
response.sendRedirect( cache.doReloadLogsConfiguration( request ) );
%>