In your function write
assert_or_return(first_arg != NULL);
assert_or_return(second_arg != NULL);
Define assert_or_return so that in the debug version it will fire up the debugger (by calling abort), and in the release version it will log the error and return (as you want to do). I assume you're confident that returning from the function when one of the arguments is NULL will do more good than harm in the production version of your application. If by returning early you will irrevocably corrupt your users' data or cause a furnace to explode, it would be better to terminate early, perhaps with a custom error message.
The following example illustrates how your idea can be implemented.
#ifdef NDEBUG
#define assert_or_return(expr) do { \
if (!(expr)) { \
fprintf(logfile, "Assertion %s in %s(%d) failed\n", #expr, __FILE__, __LINE__); \
return 0; \
} \
} while(0)
#else
#define assert_or_return(expr) do { \
if (!(expr)) { \
fprintf(stderr, "Assertion %s in %s(%d) failed\n", #expr, __FILE__, __LINE__); \
abort(); \
} \
} while(0)
#endif